From 89344a7c3625a6c414e64f9ee5437f2ad19b15ac Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Fri, 8 Oct 2021 15:27:20 +0200 Subject: [PATCH] Close loginTab after login was done by user --- src/background/runtime.background.ts | 2 ++ src/browser/browserApi.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 5c0e799a92..f93c805b19 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -77,6 +77,8 @@ export default class RuntimeBackground { if (this.lockedVaultPendingNotifications.length > 0) { const retryItem = this.lockedVaultPendingNotifications.pop(); await this.processMessage(retryItem.msg, retryItem.sender, null); + + await BrowserApi.closeLoginTab(); } break; case 'addToLockedVaultPendingNotifications': diff --git a/src/browser/browserApi.ts b/src/browser/browserApi.ts index 7e592a16db..87e269ec5d 100644 --- a/src/browser/browserApi.ts +++ b/src/browser/browserApi.ts @@ -97,6 +97,20 @@ export class BrowserApi { }); } + static async closeLoginTab() { + const tabs = await BrowserApi.tabsQuery({ + active: true, + title: 'Bitwarden', + }); + + if (tabs.length === 0) { + return; + } + + const tabToClose = tabs[tabs.length - 1].id; + chrome.tabs.remove(tabToClose); + } + static closePopup(win: Window) { if (BrowserApi.isWebExtensionsApi && BrowserApi.isFirefoxOnAndroid) { // Reactivating the active tab dismisses the popup tab. The promise final