1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-26 12:25:20 +01:00

Resolve hasKeyStored returning true when no biometric key is stored (#671)

* Resolve hasKeyStored returning true when no biometric key is stored

* Change to use a switch statement which avoids having to fetch the key.

* Use triple equals

* Run prettier
This commit is contained in:
Oscar Hinton 2022-02-11 13:17:51 +01:00 committed by GitHub
parent b0f735814f
commit fd0410ca4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -347,12 +347,14 @@ export class CryptoService implements CryptoServiceAbstraction {
} }
async hasKeyStored(keySuffix: KeySuffixOptions, userId?: string): Promise<boolean> { async hasKeyStored(keySuffix: KeySuffixOptions, userId?: string): Promise<boolean> {
const key = switch (keySuffix) {
keySuffix === KeySuffixOptions.Auto case KeySuffixOptions.Auto:
? await this.stateService.getCryptoMasterKeyAuto({ userId: userId }) return (await this.stateService.getCryptoMasterKeyAuto({ userId: userId })) != null;
: await this.stateService.hasCryptoMasterKeyBiometric({ userId: userId }); case KeySuffixOptions.Biometric:
return (await this.stateService.hasCryptoMasterKeyBiometric({ userId: userId })) === true;
return key != null; default:
return false;
}
} }
async hasEncKey(): Promise<boolean> { async hasEncKey(): Promise<boolean> {