From 0cfe18ac4df0dc4e434d3a3d61763d828feaf7b2 Mon Sep 17 00:00:00 2001 From: Brandon Treston Date: Wed, 13 Nov 2024 14:34:43 -0500 Subject: [PATCH] [PM-13829] Add check for empty array when deleting unassigned items (#11927) * add check for empty array --------- Co-authored-by: Matt Bishop --- libs/angular/src/vault/components/add-edit.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/angular/src/vault/components/add-edit.component.ts b/libs/angular/src/vault/components/add-edit.component.ts index 952f2071e9..1ca2df6b73 100644 --- a/libs/angular/src/vault/components/add-edit.component.ts +++ b/libs/angular/src/vault/components/add-edit.component.ts @@ -713,7 +713,11 @@ export class AddEditComponent implements OnInit, OnDestroy { } protected deleteCipher() { - const asAdmin = this.organization?.canEditAllCiphers || !this.cipher.collectionIds; + // cipher.collectionIds may be null or an empty array. Either is a valid indication that the item is unassigned. + const asAdmin = + this.organization?.canEditAllCiphers || + !this.cipher.collectionIds || + this.cipher.collectionIds.length === 0; return this.cipher.isDeleted ? this.cipherService.deleteWithServer(this.cipher.id, asAdmin) : this.cipherService.softDeleteWithServer(this.cipher.id, asAdmin);