From 171d9511db13582bb1732d63a6bddb496956a97e Mon Sep 17 00:00:00 2001 From: Jared Snider Date: Thu, 23 Jan 2025 18:28:27 -0500 Subject: [PATCH] PM-8113 - Update ExtensionTwoFactorAuthComponentService to close email 2FA single action popouts. --- ...nsion-two-factor-auth-component.service.ts | 22 ++++++++++++++----- ...two-factor-auth-email-component.service.ts | 3 ++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/browser/src/auth/services/extension-two-factor-auth-component.service.ts b/apps/browser/src/auth/services/extension-two-factor-auth-component.service.ts index 03d76dd47f..f7317c3200 100644 --- a/apps/browser/src/auth/services/extension-two-factor-auth-component.service.ts +++ b/apps/browser/src/auth/services/extension-two-factor-auth-component.service.ts @@ -9,7 +9,8 @@ import BrowserPopupUtils from "../../platform/popup/browser-popup-utils"; import { AuthPopoutType, closeSsoAuthResultPopout, - closeTwoFactorAuthPopout, + closeTwoFactorAuthEmailPopout, + closeTwoFactorAuthWebAuthnPopout, } from "../popup/utils/auth-popout-window"; export class ExtensionTwoFactorAuthComponentService @@ -67,13 +68,24 @@ export class ExtensionTwoFactorAuthComponentService return; } - const inTwoFactorAuthPopout = BrowserPopupUtils.inSingleActionPopout( + const inTwoFactorAuthWebAuthnPopout = BrowserPopupUtils.inSingleActionPopout( this.window, - AuthPopoutType.twoFactorAuth, + AuthPopoutType.twoFactorAuthWebAuthn, ); - if (inTwoFactorAuthPopout) { - await closeTwoFactorAuthPopout(); + if (inTwoFactorAuthWebAuthnPopout) { + await closeTwoFactorAuthWebAuthnPopout(); + return; + } + + const inTwoFactorAuthEmailPopout = BrowserPopupUtils.inSingleActionPopout( + this.window, + AuthPopoutType.twoFactorAuthEmail, + ); + + if (inTwoFactorAuthEmailPopout) { + await closeTwoFactorAuthEmailPopout(); + return; } } diff --git a/apps/browser/src/auth/services/extension-two-factor-auth-email-component.service.ts b/apps/browser/src/auth/services/extension-two-factor-auth-email-component.service.ts index 10d203d3a8..f09b7a147f 100644 --- a/apps/browser/src/auth/services/extension-two-factor-auth-email-component.service.ts +++ b/apps/browser/src/auth/services/extension-two-factor-auth-email-component.service.ts @@ -4,6 +4,7 @@ import { } from "@bitwarden/auth/angular"; import { DialogService } from "@bitwarden/components"; +import { openTwoFactorAuthEmailPopout } from "../../auth/popup/utils/auth-popout-window"; import BrowserPopupUtils from "../../platform/popup/browser-popup-utils"; // TODO: popup state persistence should eventually remove the need for this service @@ -26,7 +27,7 @@ export class ExtensionTwoFactorAuthEmailComponentService type: "warning", }); if (confirmed) { - await BrowserPopupUtils.openCurrentPagePopout(this.window); + await openTwoFactorAuthEmailPopout(); } } }