1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +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> {
const key =
keySuffix === KeySuffixOptions.Auto
? await this.stateService.getCryptoMasterKeyAuto({ userId: userId })
: await this.stateService.hasCryptoMasterKeyBiometric({ userId: userId });
return key != null;
switch (keySuffix) {
case KeySuffixOptions.Auto:
return (await this.stateService.getCryptoMasterKeyAuto({ userId: userId })) != null;
case KeySuffixOptions.Biometric:
return (await this.stateService.hasCryptoMasterKeyBiometric({ userId: userId })) === true;
default:
return false;
}
}
async hasEncKey(): Promise<boolean> {