1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-07 12:13:45 +00:00

navigate directly to the at risk passwords page

This commit is contained in:
Nick Krantz
2025-03-28 11:19:17 -05:00
parent 35efd42c7c
commit f8145d8f60
2 changed files with 37 additions and 18 deletions

View File

@@ -1612,6 +1612,17 @@ export default class MainBackground {
}
}
/** Opens the `/at-risk-passwords` page within the popup */
async openAtRisksPasswordsPage() {
const browserAction = BrowserApi.getBrowserAction();
// Set route of the popup before attempting to open it.
// If the vault is locked, this won't have an effect as the auth guards will
// redirect the user to the login page.
await browserAction.setPopup({ popup: "popup/index.html#/at-risk-passwords" });
await this.openPopup();
}
async reseedStorage() {
if (
!this.platformUtilsService.isChrome() &&

View File

@@ -17,6 +17,7 @@ import { devFlagEnabled } from "@bitwarden/common/platform/misc/flags";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { CipherType } from "@bitwarden/common/vault/enums";
import { VaultMessages } from "@bitwarden/common/vault/enums/vault-messages.enum";
import { BiometricsCommands } from "@bitwarden/key-management";
import {
@@ -289,6 +290,10 @@ export default class RuntimeBackground {
case "openPopup":
await this.openPopup();
break;
case VaultMessages.OpenAtRiskPasswords:
await this.main.openAtRisksPasswordsPage();
this.announcePopupOpen();
break;
case "bgUpdateContextMenu":
case "editedCipher":
case "addedCipher":
@@ -418,24 +423,6 @@ export default class RuntimeBackground {
private async openPopup() {
await this.main.openPopup();
const announcePopupOpen = async () => {
const isOpen = await this.platformUtilsService.isViewOpen();
const tabs = await this.getBwTabs();
if (isOpen && tabs.length > 0) {
// Send message to all vault tabs that the extension has opened
for (const tab of tabs) {
await BrowserApi.executeScriptInTab(tab.id, {
file: "content/send-popup-open-message.js",
runAt: "document_end",
});
}
}
};
// Give the popup a buffer to open
setTimeout(announcePopupOpen, 100);
}
async sendBwInstalledMessageToVault() {
@@ -456,4 +443,25 @@ export default class RuntimeBackground {
this.logService.error(`Error sending on installed message to vault: ${e}`);
}
}
/** Sends a message to each tab that the popup was opened */
private announcePopupOpen() {
const announceToAllTabs = async () => {
const isOpen = await this.platformUtilsService.isViewOpen();
const tabs = await this.getBwTabs();
if (isOpen && tabs.length > 0) {
// Send message to all vault tabs that the extension has opened
for (const tab of tabs) {
await BrowserApi.executeScriptInTab(tab.id, {
file: "content/send-popup-open-message.js",
runAt: "document_end",
});
}
}
};
// Give the popup a buffer to complete opening
setTimeout(announceToAllTabs, 100);
}
}