From af5898a00183047c4dc4059413b91be50881f9d4 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 6 May 2021 20:19:48 +0200 Subject: [PATCH] Add setting for disabling auto prompt of biometrics (#873) * Add setting for disabling auto prompt of biometrics * Ensure window is visible before prompting for biometrics --- jslib | 2 +- src/app/accounts/lock.component.ts | 13 +++++++++++-- src/app/accounts/settings.component.html | 9 +++++++++ src/app/accounts/settings.component.ts | 18 ++++++++++++++++++ src/locales/en/messages.json | 6 ++++++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/jslib b/jslib index e2cb9b6bef5..1b8f6aace24 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit e2cb9b6bef54a1bc04174aa9eec02ea800962887 +Subproject commit 1b8f6aace247d226455f2ae510cd99eac91ff8b1 diff --git a/src/app/accounts/lock.component.ts b/src/app/accounts/lock.component.ts index 3b0fcc6841b..d2fce64439b 100644 --- a/src/app/accounts/lock.component.ts +++ b/src/app/accounts/lock.component.ts @@ -7,6 +7,7 @@ import { ActivatedRoute, Router, } from '@angular/router'; +import { ipcRenderer } from 'electron'; import { ApiService } from 'jslib/abstractions/api.service'; import { CryptoService } from 'jslib/abstractions/crypto.service'; @@ -23,6 +24,8 @@ import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; import { LockComponent as BaseLockComponent } from 'jslib/angular/components/lock.component'; +import { ElectronConstants } from 'jslib/electron/electronConstants'; + const BroadcasterSubscriptionId = 'LockComponent'; @Component({ @@ -43,9 +46,15 @@ export class LockComponent extends BaseLockComponent implements OnDestroy { async ngOnInit() { await super.ngOnInit(); + const autoPromptBiometric = !await this.storageService.get(ElectronConstants.noAutoPromptBiometrics); + this.route.queryParams.subscribe(params => { - if (this.supportsBiometric && params.promptBiometric) { - setTimeout(() => this.unlockBiometric(), 1000); + if (this.supportsBiometric && params.promptBiometric && autoPromptBiometric) { + setTimeout(async() => { + if (await ipcRenderer.invoke('windowVisible')) { + this.unlockBiometric(); + } + }, 1000); } }); this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => { diff --git a/src/app/accounts/settings.component.html b/src/app/accounts/settings.component.html index a223f7c43e5..0a9eff7d0e5 100644 --- a/src/app/accounts/settings.component.html +++ b/src/app/accounts/settings.component.html @@ -52,6 +52,15 @@ +
+
+ +
+
diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 22200edc768..cf4ecb341d0 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -50,6 +50,8 @@ export class SettingsComponent implements OnInit { supportsBiometric: boolean; biometric: boolean; biometricText: string; + noAutoPromptBiometrics: boolean; + noAutoPromptBiometricsText: string; alwaysShowDock: boolean; showAlwaysShowDock: boolean = false; openAtLogin: boolean; @@ -162,6 +164,8 @@ export class SettingsComponent implements OnInit { this.supportsBiometric = await this.platformUtilsService.supportsBiometric(); this.biometric = await this.vaultTimeoutService.isBiometricLockSet(); this.biometricText = await this.storageService.get(ConstantsService.biometricText); + this.noAutoPromptBiometrics = await this.storageService.get(ElectronConstants.noAutoPromptBiometrics); + this.noAutoPromptBiometricsText = await this.storageService.get(ElectronConstants.noAutoPromptBiometricsText); this.alwaysShowDock = await this.storageService.get(ElectronConstants.alwaysShowDock); this.showAlwaysShowDock = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop; this.openAtLogin = await this.storageService.get(ElectronConstants.openAtLogin); @@ -255,11 +259,25 @@ export class SettingsComponent implements OnInit { await this.storageService.save(ConstantsService.biometricUnlockKey, true); } else { await this.storageService.remove(ConstantsService.biometricUnlockKey); + await this.storageService.remove(ElectronConstants.noAutoPromptBiometrics); + this.noAutoPromptBiometrics = false; } this.vaultTimeoutService.biometricLocked = false; await this.cryptoService.toggleKey(); } + async updateNoAutoPromptBiometrics() { + if (!this.biometric) { + this.noAutoPromptBiometrics = false; + } + + if (this.noAutoPromptBiometrics) { + await this.storageService.save(ElectronConstants.noAutoPromptBiometrics, true); + } else { + await this.storageService.remove(ElectronConstants.noAutoPromptBiometrics); + } + } + async saveFavicons() { await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicons); await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicons); diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 00f8ac62e33..e71ef622fe4 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -1297,6 +1297,12 @@ "touchIdConsentMessage": { "message": "unlock your vault" }, + "noAutoPromptWindowsHello": { + "message": "Do not prompt for Windows Hello on launch." + }, + "noAutoPromptTouchId": { + "message": "Do not prompt for Touch ID on launch." + }, "lockWithMasterPassOnRestart": { "message": "Lock with master password on restart" },