From e777842191c38849ebfed3a6027a7d346aa578a2 Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Fri, 21 Apr 2023 14:40:56 -0700 Subject: [PATCH] [AC-1343] Add bool parameter to conditionally evaluate password after successful unlock (#5260) --- .../src/auth/components/lock.component.ts | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/libs/angular/src/auth/components/lock.component.ts b/libs/angular/src/auth/components/lock.component.ts index 79f7c521b5d..9d1266de641 100644 --- a/libs/angular/src/auth/components/lock.component.ts +++ b/libs/angular/src/auth/components/lock.component.ts @@ -114,7 +114,7 @@ export class LockComponent implements OnInit, OnDestroy { const success = (await this.cryptoService.getKey(KeySuffixOptions.Biometric)) != null; if (success) { - await this.doContinue(); + await this.doContinue(false); } return success; @@ -251,37 +251,39 @@ export class LockComponent implements OnInit, OnDestroy { await this.cryptoService.encrypt(key.key, pinKey) ); } - await this.setKeyAndContinue(key); + await this.setKeyAndContinue(key, true); } - private async setKeyAndContinue(key: SymmetricCryptoKey) { + private async setKeyAndContinue(key: SymmetricCryptoKey, evaluatePasswordAfterUnlock = false) { await this.cryptoService.setKey(key); - await this.doContinue(); + await this.doContinue(evaluatePasswordAfterUnlock); } - private async doContinue() { + private async doContinue(evaluatePasswordAfterUnlock: boolean) { await this.stateService.setEverBeenUnlocked(true); const disableFavicon = await this.stateService.getDisableFavicon(); await this.stateService.setDisableFavicon(!!disableFavicon); this.messagingService.send("unlocked"); - try { - // If we do not have any saved policies, attempt to load them from the service - if (this.enforcedMasterPasswordOptions == undefined) { - this.enforcedMasterPasswordOptions = await firstValueFrom( - this.policyService.masterPasswordPolicyOptions$() - ); - } + if (evaluatePasswordAfterUnlock) { + try { + // If we do not have any saved policies, attempt to load them from the service + if (this.enforcedMasterPasswordOptions == undefined) { + this.enforcedMasterPasswordOptions = await firstValueFrom( + this.policyService.masterPasswordPolicyOptions$() + ); + } - if (this.requirePasswordChange()) { - await this.stateService.setForcePasswordResetReason( - ForceResetPasswordReason.WeakMasterPassword - ); - this.router.navigate([this.forcePasswordResetRoute]); - return; + if (this.requirePasswordChange()) { + await this.stateService.setForcePasswordResetReason( + ForceResetPasswordReason.WeakMasterPassword + ); + this.router.navigate([this.forcePasswordResetRoute]); + return; + } + } catch (e) { + // Do not prevent unlock if there is an error evaluating policies + this.logService.error(e); } - } catch (e) { - // Do not prevent unlock if there is an error evaluating policies - this.logService.error(e); } if (this.onSuccessfulSubmit != null) {