From b7cd18b715fae00fb188f841bf4f65d43fb10489 Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Wed, 12 Feb 2020 15:11:38 -0600 Subject: [PATCH] Allow organizational admins to assign clone ownership (#458) --- src/app/organizations/vault/add-edit.component.ts | 13 ++++++++++++- src/app/vault/add-edit.component.html | 3 +-- src/app/vault/add-edit.component.ts | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/app/organizations/vault/add-edit.component.ts b/src/app/organizations/vault/add-edit.component.ts index ec0845f749..fe2c3c2c71 100644 --- a/src/app/organizations/vault/add-edit.component.ts +++ b/src/app/organizations/vault/add-edit.component.ts @@ -42,6 +42,17 @@ export class AddEditComponent extends BaseAddEditComponent { eventService); } + protected allowOwnershipAssignment() { + if (this.ownershipOptions != null && this.ownershipOptions.length > 1) { + if (this.organization != null) { + return this.cloneMode && this.organization.isAdmin; + } else { + return !this.editMode || this.cloneMode; + } + } + return false; + } + protected loadCollections() { if (!this.organization.isAdmin) { return super.loadCollections(); @@ -67,7 +78,7 @@ export class AddEditComponent extends BaseAddEditComponent { } protected async saveCipher(cipher: Cipher) { - if (!this.organization.isAdmin) { + if (!this.organization.isAdmin || cipher.organizationId == null) { return super.saveCipher(cipher); } if (this.editMode && !this.cloneMode) { diff --git a/src/app/vault/add-edit.component.html b/src/app/vault/add-edit.component.html index 176cad8ae0..6794974b14 100644 --- a/src/app/vault/add-edit.component.html +++ b/src/app/vault/add-edit.component.html @@ -439,8 +439,7 @@ - +

{{'ownership' | i18n}}

diff --git a/src/app/vault/add-edit.component.ts b/src/app/vault/add-edit.component.ts index b5348f47d4..cfac7b3759 100644 --- a/src/app/vault/add-edit.component.ts +++ b/src/app/vault/add-edit.component.ts @@ -154,6 +154,10 @@ export class AddEditComponent extends BaseAddEditComponent { } } + protected allowOwnershipAssignment() { + return (!this.editMode || this.cloneMode) && this.ownershipOptions != null && this.ownershipOptions.length > 1; + } + private async totpTick(intervalSeconds: number) { const epoch = Math.round(new Date().getTime() / 1000.0); const mod = epoch % intervalSeconds;