mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-06 18:57:56 +01:00
clear deprecated keys when setting new user key
This commit is contained in:
parent
0bbba9c6f7
commit
156c58fd94
@ -36,6 +36,7 @@ export class ElectronCryptoService extends CryptoService {
|
||||
} else {
|
||||
await this.stateService.setUserKeyBiometric(null, { userId: userId });
|
||||
}
|
||||
await this.stateService.setCryptoMasterKeyBiometric(null, { userId: userId });
|
||||
}
|
||||
|
||||
protected override async getKeyFromStorage(
|
||||
|
@ -50,7 +50,7 @@ export class SetPinComponent implements OnInit {
|
||||
} else {
|
||||
await this.stateService.setUserKeyPin(pinProtectedKey);
|
||||
}
|
||||
await this.cryptoService.clearOldPinKeys();
|
||||
await this.cryptoService.clearDeprecatedPinKeys();
|
||||
|
||||
this.modalRef.close(true);
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ export abstract class CryptoService {
|
||||
* Clears the user's old pin keys from storage
|
||||
* @param userId The desired user
|
||||
*/
|
||||
clearOldPinKeys: (userId?: string) => Promise<void>;
|
||||
clearDeprecatedPinKeys: (userId?: string) => Promise<void>;
|
||||
/**
|
||||
* Decrypts the user key with their pin
|
||||
* @param pin The user's PIN
|
||||
|
@ -513,10 +513,10 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
|
||||
async clearPinProtectedKey(userId?: string): Promise<void> {
|
||||
await this.stateService.setUserKeyPin(null, { userId: userId });
|
||||
await this.clearOldPinKeys(userId);
|
||||
await this.clearDeprecatedPinKeys(userId);
|
||||
}
|
||||
|
||||
async clearOldPinKeys(userId?: string): Promise<void> {
|
||||
async clearDeprecatedPinKeys(userId?: string): Promise<void> {
|
||||
await this.stateService.setEncryptedPinProtected(null, { userId: userId });
|
||||
await this.stateService.setDecryptedPinProtected(null, { userId: userId });
|
||||
}
|
||||
@ -714,10 +714,12 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
} else {
|
||||
await this.stateService.setUserKeyAuto(null, { userId: userId });
|
||||
}
|
||||
await this.stateService.setCryptoMasterKeyAuto(null, { userId: userId });
|
||||
|
||||
const storePin = await this.shouldStoreKey(KeySuffixOptions.Pin, userId);
|
||||
if (storePin) {
|
||||
await this.storePinKey(key);
|
||||
await this.clearDeprecatedPinKeys(userId);
|
||||
} else {
|
||||
await this.stateService.setUserKeyPin(null, { userId: userId });
|
||||
}
|
||||
|
@ -118,6 +118,6 @@ export class VaultTimeoutSettingsService implements VaultTimeoutSettingsServiceA
|
||||
await this.stateService.setEverBeenUnlocked(false, { userId: userId });
|
||||
await this.stateService.setUserKeyPinEphemeral(null, { userId: userId });
|
||||
await this.stateService.setProtectedPin(null, { userId: userId });
|
||||
await this.cryptoService.clearOldPinKeys(userId);
|
||||
await this.cryptoService.clearDeprecatedPinKeys(userId);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user