From 1e86220e3ca7cfef8609f12662fdd2a5103f961f Mon Sep 17 00:00:00 2001 From: Alec Rippberger Date: Wed, 5 Mar 2025 11:21:43 -0600 Subject: [PATCH] Check cache before sending email for v1 component --- apps/browser/src/auth/popup/two-factor-v1.component.ts | 3 ++- libs/angular/src/auth/components/two-factor-v1.component.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/browser/src/auth/popup/two-factor-v1.component.ts b/apps/browser/src/auth/popup/two-factor-v1.component.ts index 726c5a026d2..be080dcf917 100644 --- a/apps/browser/src/auth/popup/two-factor-v1.component.ts +++ b/apps/browser/src/auth/popup/two-factor-v1.component.ts @@ -69,7 +69,7 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn toastService: ToastService, @Inject(WINDOW) protected win: Window, private browserMessagingApi: ZonedMessageListenerService, - private twoFactorFormCacheService: TwoFactorFormCacheService, + protected twoFactorFormCacheService: TwoFactorFormCacheService, ) { super( loginStrategyService, @@ -91,6 +91,7 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn masterPasswordService, accountService, toastService, + twoFactorFormCacheService, ); this.onSuccessfulLogin = async () => { // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. diff --git a/libs/angular/src/auth/components/two-factor-v1.component.ts b/libs/angular/src/auth/components/two-factor-v1.component.ts index 4cbaa9362f2..72492c1fdca 100644 --- a/libs/angular/src/auth/components/two-factor-v1.component.ts +++ b/libs/angular/src/auth/components/two-factor-v1.component.ts @@ -8,6 +8,7 @@ import { first } from "rxjs/operators"; // eslint-disable-next-line no-restricted-imports import { WINDOW } from "@bitwarden/angular/services/injection-tokens"; +import { TwoFactorFormCacheService } from "@bitwarden/auth/angular"; import { LoginStrategyServiceAbstraction, LoginEmailServiceAbstraction, @@ -100,6 +101,7 @@ export class TwoFactorComponentV1 extends CaptchaProtectedComponent implements O protected masterPasswordService: InternalMasterPasswordServiceAbstraction, protected accountService: AccountService, protected toastService: ToastService, + protected twoFactorFormCacheService: TwoFactorFormCacheService, ) { super(environmentService, i18nService, platformUtilsService, toastService); @@ -438,6 +440,10 @@ export class TwoFactorComponentV1 extends CaptchaProtectedComponent implements O return; } + if ((await this.twoFactorFormCacheService.getFormData()).emailSent) { + return; + } + if ((await this.loginStrategyService.getEmail()) == null) { this.toastService.showToast({ variant: "error",