Skip to content

Commit

Permalink
[PM-13829] Add check for empty array when deleting unassigned items (#…
Browse files Browse the repository at this point in the history
…11927)

* add check for empty array

---------

Co-authored-by: Matt Bishop <[email protected]>
  • Loading branch information
BTreston and withinfocus authored Nov 13, 2024
1 parent 3a293bb commit 0cfe18a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libs/angular/src/vault/components/add-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0cfe18a

Please sign in to comment.