mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-22516] Fix cipher key decryption to handle new error-based API instead of null returns (#15124)
* Replace null check in cipher key decryption * Handle decryption error properly in user asymmetric key regeneration service
This commit is contained in:
@@ -162,17 +162,26 @@ export class DefaultUserAsymmetricKeysRegenerationService
|
||||
const ciphers = await this.cipherService.getAll(userId);
|
||||
const cipher = ciphers.find((cipher) => cipher.organizationId == null);
|
||||
|
||||
if (cipher != null) {
|
||||
try {
|
||||
await cipher.decrypt(userKey);
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (!cipher) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const cipherView = await cipher.decrypt(userKey);
|
||||
|
||||
if (cipherView.decryptionFailure) {
|
||||
this.logService.error(
|
||||
"[UserAsymmetricKeyRegeneration] User Symmetric Key validation error: " + error,
|
||||
"[UserAsymmetricKeyRegeneration] User Symmetric Key validation error: Cipher decryption failed",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
this.logService.error(
|
||||
"[UserAsymmetricKeyRegeneration] User Symmetric Key validation error: " + error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user