mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
[PM-21705] Require userID for refreshAdditionalKeys() on key-service (#14810)
* Require userID for refreshAdditionalKeys() * Add error handling to desktop Unlock settings * Add more unit test coverage
This commit is contained in:
@@ -122,15 +122,17 @@ export class DefaultKeyService implements KeyServiceAbstraction {
|
||||
await this.setPrivateKey(encPrivateKey, userId);
|
||||
}
|
||||
|
||||
async refreshAdditionalKeys(): Promise<void> {
|
||||
const activeUserId = await firstValueFrom(this.stateProvider.activeUserId$);
|
||||
|
||||
if (activeUserId == null) {
|
||||
throw new Error("Can only refresh keys while there is an active user.");
|
||||
async refreshAdditionalKeys(userId: UserId): Promise<void> {
|
||||
if (userId == null) {
|
||||
throw new Error("UserId is required.");
|
||||
}
|
||||
|
||||
const key = await this.getUserKey(activeUserId);
|
||||
await this.setUserKey(key, activeUserId);
|
||||
const key = await firstValueFrom(this.userKey$(userId));
|
||||
if (key == null) {
|
||||
throw new Error("No user key found for: " + userId);
|
||||
}
|
||||
|
||||
await this.setUserKey(key, userId);
|
||||
}
|
||||
|
||||
everHadUserKey$(userId: UserId): Observable<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user