1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

Correctly set biometric state on connect failure

This commit is contained in:
Hinton 2020-11-30 13:41:08 +01:00
parent 951e2f0e51
commit 7c468de97c
3 changed files with 15 additions and 7 deletions

View File

@ -152,10 +152,16 @@ export default class MainBackground {
this.systemService.clearClipboard(clipboardValue, clearMs);
}
},
() => {
async () => {
if (this.nativeMessagingBackground != null) {
const promise = this.nativeMessagingBackground.getResponse();
this.nativeMessagingBackground.send({command: 'biometricUnlock'})
try {
await this.nativeMessagingBackground.send({command: 'biometricUnlock'});
} catch (e) {
return Promise.reject(e);
}
return promise.then((result) => result.response === 'unlocked');
}
});

View File

@ -44,7 +44,7 @@
</div>
<div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="biometric">{{'unlockWithBiometrics' | i18n}}</label>
<input id="biometric" type="checkbox" (change)="updateBiometric()" [checked]="biometric">
<input id="biometric" type="checkbox" (change)="updateBiometric()" [(ngModel)]="biometric">
</div>
<a class="box-content-row box-content-row-flex text-default" href="#" appStopClick appBlurClick
(click)="lock()">

View File

@ -208,10 +208,6 @@ export class SettingsComponent implements OnInit {
async updateBiometric() {
if (this.biometric) {
this.biometric = false;
await this.storageService.remove(ConstantsService.biometricUnlockKey);
this.vaultTimeoutService.biometricLocked = false;
} else {
const submitted = Swal.fire({
heightAuto: false,
buttonsStyling: false,
@ -242,8 +238,14 @@ export class SettingsComponent implements OnInit {
if (this.biometric === false) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorEnableBiometricTitle'), this.i18nService.t('errorEnableBiometricDesc'));
}
}).catch((e) => {
// Handle connection errors
this.biometric = false;
})
]);
} else {
await this.storageService.remove(ConstantsService.biometricUnlockKey);
this.vaultTimeoutService.biometricLocked = false;
}
}