From d9bec7f9846c8b2be8ac02bef8f8521733a46ba6 Mon Sep 17 00:00:00 2001 From: Jake Fink Date: Wed, 27 Mar 2024 17:22:56 -0400 Subject: [PATCH] send captcha bypass token on 2fa token request (#8511) --- .../password-login.strategy.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libs/auth/src/common/login-strategies/password-login.strategy.ts b/libs/auth/src/common/login-strategies/password-login.strategy.ts index 427f8178e4..d3de3ea6ba 100644 --- a/libs/auth/src/common/login-strategies/password-login.strategy.ts +++ b/libs/auth/src/common/login-strategies/password-login.strategy.ts @@ -37,15 +37,11 @@ export class PasswordLoginStrategyData implements LoginStrategyData { /** User's entered email obtained pre-login. Always present in MP login. */ userEnteredEmail: string; - + /** If 2fa is required, token is returned to bypass captcha */ captchaBypassToken?: string; - /** - * The local version of the user's master key hash - */ + /** The local version of the user's master key hash */ localMasterKeyHash: string; - /** - * The user's master key - */ + /** The user's master key */ masterKey: MasterKey; /** * Tracks if the user needs to update their password due to @@ -175,10 +171,10 @@ export class PasswordLoginStrategy extends LoginStrategy { twoFactor: TokenTwoFactorRequest, captchaResponse: string, ): Promise { - this.cache.next({ - ...this.cache.value, - captchaBypassToken: captchaResponse ?? this.cache.value.captchaBypassToken, - }); + const data = this.cache.value; + data.tokenRequest.captchaResponse = captchaResponse ?? data.captchaBypassToken; + this.cache.next(data); + const result = await super.logInTwoFactor(twoFactor); // 2FA was successful, save the force update password options with the state service if defined