From 3e11a9b092dcb1cc32ee7b44f2b86a97e798b4dd Mon Sep 17 00:00:00 2001 From: Jacob Fink Date: Mon, 26 Jun 2023 16:42:34 -0400 Subject: [PATCH] migrate master key if found --- libs/common/src/platform/services/crypto.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/common/src/platform/services/crypto.service.ts b/libs/common/src/platform/services/crypto.service.ts index 5087fef896..58401283e1 100644 --- a/libs/common/src/platform/services/crypto.service.ts +++ b/libs/common/src/platform/services/crypto.service.ts @@ -149,7 +149,10 @@ export class CryptoService implements CryptoServiceAbstraction { async getMasterKey(userId?: string): Promise { let masterKey = await this.stateService.getMasterKey({ userId: userId }); - masterKey ||= (await this.stateService.getCryptoMasterKey({ userId: userId })) as MasterKey; + if (!masterKey) { + masterKey = (await this.stateService.getCryptoMasterKey({ userId: userId })) as MasterKey; + await this.setMasterKey(masterKey, userId); + } return masterKey; }