diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index 4c23119f1eb..07e810a0cbf 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -550,15 +550,7 @@ export class VaultComponent implements OnInit, OnDestr await this.editCipherId(cipherId); } } else { - this.toastService.showToast({ - variant: "error", - title: null, - message: this.i18nService.t("unknownCipher"), - }); - await this.router.navigate([], { - queryParams: { itemId: null, cipherId: null }, - queryParamsHandling: "merge", - }); + await this.handleUnknownCipher(); } } }), @@ -714,6 +706,18 @@ export class VaultComponent implements OnInit, OnDestr } } + async handleUnknownCipher() { + this.toastService.showToast({ + variant: "error", + title: null, + message: this.i18nService.t("unknownCipher"), + }); + await this.router.navigate([], { + queryParams: { itemId: null, cipherId: null }, + queryParamsHandling: "merge", + }); + } + async archive(cipher: C) { const repromptPassed = await this.passwordRepromptService.passwordRepromptCheck(cipher); @@ -997,6 +1001,10 @@ export class VaultComponent implements OnInit, OnDestr async editCipherId(id: string, cloneMode?: boolean) { const activeUserId = await firstValueFrom(getUserId(this.accountService.activeAccount$)); const cipher = await this.cipherService.get(id, activeUserId); + if (!cipher) { + await this.handleUnknownCipher(); + return; + } if ( cipher && @@ -1034,6 +1042,10 @@ export class VaultComponent implements OnInit, OnDestr async viewCipherById(id: string) { const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId)); const cipher = await this.cipherService.get(id, activeUserId); + if (!cipher) { + await this.handleUnknownCipher(); + return; + } // If cipher exists (cipher is null when new) and MP reprompt // is on for this cipher, then show password reprompt. if (