diff --git a/src/abstractions/crypto.service.ts b/src/abstractions/crypto.service.ts index 7c19a3487f..9014a77726 100644 --- a/src/abstractions/crypto.service.ts +++ b/src/abstractions/crypto.service.ts @@ -17,6 +17,7 @@ export abstract class CryptoService { getOrgKeys: () => Promise>; getOrgKey: (orgId: string) => Promise; hasKey: () => Promise; + hasEncKey: () => Promise; clearKey: () => Promise; clearKeyHash: () => Promise; clearEncKey: (memoryOnly?: boolean) => Promise; diff --git a/src/angular/components/attachments.component.ts b/src/angular/components/attachments.component.ts index 6429c1cdd9..c4b287c94c 100644 --- a/src/angular/components/attachments.component.ts +++ b/src/angular/components/attachments.component.ts @@ -40,8 +40,7 @@ export class AttachmentsComponent implements OnInit { this.cipherDomain = await this.loadCipher(); this.cipher = await this.cipherDomain.decrypt(); - const key = await this.cryptoService.getEncKey(); - this.hasUpdatedKey = key != null; + this.hasUpdatedKey = await this.cryptoService.hasEncKey(); const isPremium = this.tokenService.getPremium(); this.canAccessAttachments = isPremium || this.cipher.organizationId != null; diff --git a/src/services/crypto.service.ts b/src/services/crypto.service.ts index 9d362329f9..effb5825c8 100644 --- a/src/services/crypto.service.ts +++ b/src/services/crypto.service.ts @@ -211,6 +211,11 @@ export class CryptoService implements CryptoServiceAbstraction { return (await this.getKey()) != null; } + async hasEncKey(): Promise { + const encKey = await this.storageService.get(Keys.encKey); + return encKey != null; + } + clearKey(): Promise { this.key = this.legacyEtmKey = null; return this.secureStorageService.remove(Keys.key);