From 4f84d6b0f6fa411380e9b8a9f6c57257d041ff81 Mon Sep 17 00:00:00 2001 From: Brandon Treston Date: Mon, 14 Jul 2025 15:50:13 -0400 Subject: [PATCH] fix bulk restore for unassigned items (#15533) --- .../admin-console/organizations/collections/vault.component.ts | 1 + apps/web/src/app/vault/individual-vault/vault.component.ts | 3 ++- libs/common/src/vault/abstractions/cipher.service.ts | 2 +- libs/common/src/vault/services/cipher.service.ts | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/src/app/admin-console/organizations/collections/vault.component.ts b/apps/web/src/app/admin-console/organizations/collections/vault.component.ts index 1956498322b..197fc0ada0f 100644 --- a/apps/web/src/app/admin-console/organizations/collections/vault.component.ts +++ b/apps/web/src/app/admin-console/organizations/collections/vault.component.ts @@ -1068,6 +1068,7 @@ export class VaultComponent implements OnInit, OnDestroy { if (unassignedCiphers.length > 0 || editAccessCiphers.length > 0) { await this.cipherService.restoreManyWithServer( [...unassignedCiphers, ...editAccessCiphers], + this.userId, this.organization.id, ); } diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index 52c4bcef01b..db77a2be8ea 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -1029,7 +1029,8 @@ export class VaultComponent implements OnInit, OnDestroy { return; } - await this.cipherService.restoreManyWithServer(selectedCipherIds); + const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId)); + await this.cipherService.restoreManyWithServer(selectedCipherIds, activeUserId); this.toastService.showToast({ variant: "success", title: null, diff --git a/libs/common/src/vault/abstractions/cipher.service.ts b/libs/common/src/vault/abstractions/cipher.service.ts index 91f8006d15e..9f5c173826e 100644 --- a/libs/common/src/vault/abstractions/cipher.service.ts +++ b/libs/common/src/vault/abstractions/cipher.service.ts @@ -209,7 +209,7 @@ export abstract class CipherService implements UserKeyRotationDataProvider; abstract restoreWithServer(id: string, userId: UserId, asAdmin?: boolean): Promise; - abstract restoreManyWithServer(ids: string[], orgId?: string): Promise; + abstract restoreManyWithServer(ids: string[], userId: UserId, orgId?: string): Promise; abstract getKeyForCipherKeyDecryption(cipher: Cipher, userId: UserId): Promise; abstract setAddEditCipherInfo(value: AddEditCipherInfo, userId: UserId): Promise; /** diff --git a/libs/common/src/vault/services/cipher.service.ts b/libs/common/src/vault/services/cipher.service.ts index a1727fd7a1d..18acc5238f5 100644 --- a/libs/common/src/vault/services/cipher.service.ts +++ b/libs/common/src/vault/services/cipher.service.ts @@ -1336,7 +1336,7 @@ export class CipherService implements CipherServiceAbstraction { * No longer using an asAdmin Param. Org Vault bulkRestore will assess if an item is unassigned or editable * The Org Vault will pass those ids an array as well as the orgId when calling bulkRestore */ - async restoreManyWithServer(ids: string[], userId: UserId, orgId: string = null): Promise { + async restoreManyWithServer(ids: string[], userId: UserId, orgId?: string): Promise { let response; if (orgId) {