1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

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
This commit is contained in:
Oscar Hinton 2021-05-06 20:19:48 +02:00 committed by GitHub
parent a712917f47
commit af5898a001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 3 deletions

2
jslib

@ -1 +1 @@
Subproject commit e2cb9b6bef54a1bc04174aa9eec02ea800962887 Subproject commit 1b8f6aace247d226455f2ae510cd99eac91ff8b1

View File

@ -7,6 +7,7 @@ import {
ActivatedRoute, ActivatedRoute,
Router, Router,
} from '@angular/router'; } from '@angular/router';
import { ipcRenderer } from 'electron';
import { ApiService } from 'jslib/abstractions/api.service'; import { ApiService } from 'jslib/abstractions/api.service';
import { CryptoService } from 'jslib/abstractions/crypto.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 { LockComponent as BaseLockComponent } from 'jslib/angular/components/lock.component';
import { ElectronConstants } from 'jslib/electron/electronConstants';
const BroadcasterSubscriptionId = 'LockComponent'; const BroadcasterSubscriptionId = 'LockComponent';
@Component({ @Component({
@ -43,9 +46,15 @@ export class LockComponent extends BaseLockComponent implements OnDestroy {
async ngOnInit() { async ngOnInit() {
await super.ngOnInit(); await super.ngOnInit();
const autoPromptBiometric = !await this.storageService.get<boolean>(ElectronConstants.noAutoPromptBiometrics);
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
if (this.supportsBiometric && params.promptBiometric) { if (this.supportsBiometric && params.promptBiometric && autoPromptBiometric) {
setTimeout(() => this.unlockBiometric(), 1000); setTimeout(async() => {
if (await ipcRenderer.invoke('windowVisible')) {
this.unlockBiometric();
}
}, 1000);
} }
}); });
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => { this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {

View File

@ -52,6 +52,15 @@
</label> </label>
</div> </div>
</div> </div>
<div class="form-group" *ngIf="supportsBiometric">
<div class="checkbox">
<label for="noAutoPromptBiometrics">
<input id="noAutoPromptBiometrics" type="checkbox" name="noAutoPromptBiometrics" [(ngModel)]="noAutoPromptBiometrics"
[disabled]="!biometric" (change)="updateNoAutoPromptBiometrics()">
{{noAutoPromptBiometricsText | i18n}}
</label>
</div>
</div>
</div> </div>
</div> </div>
<div class="box"> <div class="box">

View File

@ -50,6 +50,8 @@ export class SettingsComponent implements OnInit {
supportsBiometric: boolean; supportsBiometric: boolean;
biometric: boolean; biometric: boolean;
biometricText: string; biometricText: string;
noAutoPromptBiometrics: boolean;
noAutoPromptBiometricsText: string;
alwaysShowDock: boolean; alwaysShowDock: boolean;
showAlwaysShowDock: boolean = false; showAlwaysShowDock: boolean = false;
openAtLogin: boolean; openAtLogin: boolean;
@ -162,6 +164,8 @@ export class SettingsComponent implements OnInit {
this.supportsBiometric = await this.platformUtilsService.supportsBiometric(); this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
this.biometric = await this.vaultTimeoutService.isBiometricLockSet(); this.biometric = await this.vaultTimeoutService.isBiometricLockSet();
this.biometricText = await this.storageService.get<string>(ConstantsService.biometricText); this.biometricText = await this.storageService.get<string>(ConstantsService.biometricText);
this.noAutoPromptBiometrics = await this.storageService.get<boolean>(ElectronConstants.noAutoPromptBiometrics);
this.noAutoPromptBiometricsText = await this.storageService.get<string>(ElectronConstants.noAutoPromptBiometricsText);
this.alwaysShowDock = await this.storageService.get<boolean>(ElectronConstants.alwaysShowDock); this.alwaysShowDock = await this.storageService.get<boolean>(ElectronConstants.alwaysShowDock);
this.showAlwaysShowDock = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop; this.showAlwaysShowDock = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop;
this.openAtLogin = await this.storageService.get<boolean>(ElectronConstants.openAtLogin); this.openAtLogin = await this.storageService.get<boolean>(ElectronConstants.openAtLogin);
@ -255,11 +259,25 @@ export class SettingsComponent implements OnInit {
await this.storageService.save(ConstantsService.biometricUnlockKey, true); await this.storageService.save(ConstantsService.biometricUnlockKey, true);
} else { } else {
await this.storageService.remove(ConstantsService.biometricUnlockKey); await this.storageService.remove(ConstantsService.biometricUnlockKey);
await this.storageService.remove(ElectronConstants.noAutoPromptBiometrics);
this.noAutoPromptBiometrics = false;
} }
this.vaultTimeoutService.biometricLocked = false; this.vaultTimeoutService.biometricLocked = false;
await this.cryptoService.toggleKey(); 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() { async saveFavicons() {
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicons); await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicons);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicons); await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicons);

View File

@ -1297,6 +1297,12 @@
"touchIdConsentMessage": { "touchIdConsentMessage": {
"message": "unlock your vault" "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": { "lockWithMasterPassOnRestart": {
"message": "Lock with master password on restart" "message": "Lock with master password on restart"
}, },