From 7b3f8d42235aa2ff4baecb445ce79083dd79e6f1 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Tue, 16 Nov 2021 14:14:48 +1000 Subject: [PATCH 1/2] Don't save passwords if user is logged out --- src/background/main.background.ts | 2 +- src/background/notification.background.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 11ebc51f85..a140371e52 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -256,7 +256,7 @@ export default class MainBackground { this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService, this.platformUtilsService, this.vaultTimeoutService); this.notificationBackground = new NotificationBackground(this, this.autofillService, this.cipherService, - this.storageService, this.vaultTimeoutService, this.policyService, this.folderService); + this.storageService, this.vaultTimeoutService, this.policyService, this.folderService, this.userService); this.tabsBackground = new TabsBackground(this, this.notificationBackground); this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService, this.passwordGenerationService, diff --git a/src/background/notification.background.ts b/src/background/notification.background.ts index 90311f4e73..6024da710b 100644 --- a/src/background/notification.background.ts +++ b/src/background/notification.background.ts @@ -8,8 +8,11 @@ import { CipherService } from 'jslib-common/abstractions/cipher.service'; import { FolderService } from 'jslib-common/abstractions/folder.service'; import { PolicyService } from 'jslib-common/abstractions/policy.service'; import { StorageService } from 'jslib-common/abstractions/storage.service'; +import { UserService } from 'jslib-common/abstractions/user.service'; import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service'; + import { ConstantsService } from 'jslib-common/services/constants.service'; + import { AutofillService } from '../services/abstractions/autofill.service'; import { BrowserApi } from '../browser/browserApi'; @@ -34,7 +37,7 @@ export default class NotificationBackground { constructor(private main: MainBackground, private autofillService: AutofillService, private cipherService: CipherService, private storageService: StorageService, private vaultTimeoutService: VaultTimeoutService, private policyService: PolicyService, - private folderService: FolderService) { + private folderService: FolderService, private userService: UserService) { } async init() { @@ -191,7 +194,7 @@ export default class NotificationBackground { normalizedUsername = normalizedUsername.toLowerCase(); } - if (await this.vaultTimeoutService.isLocked()) { + if (await this.userService.isAuthenticated() && await this.vaultTimeoutService.isLocked()) { if (!await this.allowPersonalOwnership()) { return; } From daf20bbf572b00fe59352d2632e4c1ecc478073d Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Tue, 16 Nov 2021 13:34:06 +0100 Subject: [PATCH 2/2] Do not prompt for new login if user is not logged in --- src/background/notification.background.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/background/notification.background.ts b/src/background/notification.background.ts index 6024da710b..6a5ac80d34 100644 --- a/src/background/notification.background.ts +++ b/src/background/notification.background.ts @@ -184,6 +184,10 @@ export default class NotificationBackground { } private async addLogin(loginInfo: AddLoginRuntimeMessage, tab: chrome.tabs.Tab) { + if (!await this.userService.isAuthenticated()) { + return; + } + const loginDomain = Utils.getDomain(loginInfo.url); if (loginDomain == null) { return; @@ -194,7 +198,7 @@ export default class NotificationBackground { normalizedUsername = normalizedUsername.toLowerCase(); } - if (await this.userService.isAuthenticated() && await this.vaultTimeoutService.isLocked()) { + if (await this.vaultTimeoutService.isLocked()) { if (!await this.allowPersonalOwnership()) { return; }