diff --git a/apps/browser/src/auth/popup/two-factor.component.ts b/apps/browser/src/auth/popup/two-factor.component.ts index 678675ba38..99a850d3c0 100644 --- a/apps/browser/src/auth/popup/two-factor.component.ts +++ b/apps/browser/src/auth/popup/two-factor.component.ts @@ -118,10 +118,20 @@ export class TwoFactorComponent extends BaseTwoFactorComponent { this.route.queryParams.pipe(first()).subscribe(async (qParams) => { if (qParams.sso === "true") { super.onSuccessfulLogin = () => { - BrowserApi.reloadOpenWindows(); - const thisWindow = window.open("", "_self"); - thisWindow.close(); - return this.syncService.fullSync(true); + // This is not awaited so we don't pause the application while the sync is happening. + // This call is executed by the service that lives in the background script so it will continue + // the sync even if this tab closes. + const syncPromise = this.syncService.fullSync(true); + + // Force sidebars (FF && Opera) to reload while exempting current window + // because we are just going to close the current window. + BrowserApi.reloadOpenWindows(true); + + // We don't need this window anymore because the intent is for the user to be left + // on the web vault screen which tells them to continue in the browser extension (sidebar or popup) + BrowserApi.closeBitwardenExtensionTab(); + + return syncPromise; }; } }); diff --git a/apps/browser/src/browser/browserApi.ts b/apps/browser/src/browser/browserApi.ts index b1313ebda6..b69cf388de 100644 --- a/apps/browser/src/browser/browserApi.ts +++ b/apps/browser/src/browser/browserApi.ts @@ -227,10 +227,12 @@ export class BrowserApi { } } - static reloadOpenWindows() { + static reloadOpenWindows(exemptCurrentHref = false) { + const currentHref = window.location.href; const views = chrome.extension.getViews() as Window[]; views .filter((w) => w.location.href != null && !w.location.href.includes("background.html")) + .filter((w) => !exemptCurrentHref || w.location.href !== currentHref) .forEach((w) => { w.location.reload(); });