mirror of
https://github.com/bitwarden/browser.git
synced 2025-03-11 13:30:39 +01:00
clean up the old pin keys in more flows
- in the case that the app is updated while logged in and the user changes their pin, this will clear the old pin keys
This commit is contained in:
parent
62c43794e9
commit
7963d3c996
@ -50,6 +50,7 @@ export class SetPinComponent implements OnInit {
|
||||
} else {
|
||||
await this.stateService.setUserSymKeyPin(pinProtectedKey);
|
||||
}
|
||||
await this.cryptoService.clearOldPinKeys();
|
||||
|
||||
this.modalRef.close(true);
|
||||
}
|
||||
|
@ -73,7 +73,8 @@ export abstract class CryptoService {
|
||||
makeKeyPair: (key?: SymmetricCryptoKey) => Promise<[string, EncString]>;
|
||||
clearKeyPair: (memoryOnly?: boolean, userId?: string) => Promise<void[]>;
|
||||
makePinKey: (pin: string, salt: string, kdf: KdfType, kdfConfig: KdfConfig) => Promise<PinKey>;
|
||||
clearPinProtectedKey: () => Promise<void>;
|
||||
clearPinProtectedKey: (userId?: string) => Promise<void>;
|
||||
clearOldPinKeys: (userId?: string) => Promise<void>;
|
||||
/**
|
||||
* Decrypts the user's symmetric key with their pin
|
||||
* @param pin The user's PIN
|
||||
|
@ -676,7 +676,12 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
*/
|
||||
async clearPinProtectedKey(userId?: string): Promise<void> {
|
||||
await this.stateService.setUserSymKeyPin(null, { userId: userId });
|
||||
await this.clearOldPinKeys(userId);
|
||||
}
|
||||
|
||||
async clearOldPinKeys(userId?: string): Promise<void> {
|
||||
await this.stateService.setEncryptedPinProtected(null, { userId: userId });
|
||||
await this.stateService.setDecryptedPinProtected(null, { userId: userId });
|
||||
}
|
||||
|
||||
async decryptUserSymKeyWithPin(
|
||||
@ -889,7 +894,6 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
await this.stateService.setUserSymKeyAuto(key.keyB64, { userId: userId });
|
||||
} else {
|
||||
await this.stateService.setUserSymKeyAuto(null, { userId: userId });
|
||||
await this.stateService.setCryptoMasterKeyAuto(null, { userId: userId });
|
||||
}
|
||||
|
||||
const storePin = await this.shouldStoreKey(KeySuffixOptions.Pin, userId);
|
||||
@ -897,7 +901,6 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
await this.storePinKey(key);
|
||||
} else {
|
||||
await this.stateService.setUserSymKeyPin(null, { userId: userId });
|
||||
await this.stateService.setEncryptedPinProtected(null, { userId: userId });
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user