From 41d6b6bd2168ae65cdb6e3ae28e4e16b633fe09b Mon Sep 17 00:00:00 2001 From: dgoodman-bw <109169446+dgoodman-bw@users.noreply.github.com> Date: Tue, 25 Oct 2022 12:24:21 -0700 Subject: [PATCH] Ps 976 moving of read only organization collection items to different folder not possible (#3474) * PS-976 - when user has cipher readonly permissions, prevent user from editing cipher fields and make separate api call that only updates Favorite and Folder values * PS-976 - in the readonly edit cipher view, hide non-operable buttons and display select values as readonly input text * PS-976 - update failing test * PS-976 - split cipher saveWithServer call into Create and Update calls * PS-976 - replace property with function call to get the card expiration month for the readonly view * MM-976 - when user has readonly permissions hide "delete" button on View Item view, hide generate username/password buttons on Edit Item view * PS-976 - rename cipherPartialRequest file to align with new naming convention --- .../src/background/notification.background.ts | 4 +- .../add-edit-custom-fields.component.html | 18 ++- .../src/popup/vault/add-edit.component.html | 107 +++++++++++--- .../src/popup/vault/view.component.html | 8 +- .../browser/src/popup/vault/view.component.ts | 2 +- apps/cli/src/commands/create.command.ts | 2 +- apps/cli/src/commands/edit.command.ts | 2 +- .../add-edit-custom-fields.component.html | 14 +- .../src/app/vault/add-edit.component.html | 107 ++++++++++++-- .../desktop/src/app/vault/view.component.html | 2 +- .../encryptedMessageHandlerService.ts | 4 +- .../add-edit-custom-fields.component.html | 11 +- .../web/src/app/vault/add-edit.component.html | 136 +++++++++++++----- .../src/components/add-edit.component.ts | 8 +- libs/common/src/abstractions/api.service.ts | 2 + .../common/src/abstractions/cipher.service.ts | 3 +- .../models/request/cipher-partial.request.ts | 11 ++ libs/common/src/services/api.service.ts | 6 + libs/common/src/services/cipher.service.ts | 31 ++-- 19 files changed, 382 insertions(+), 96 deletions(-) create mode 100644 libs/common/src/models/request/cipher-partial.request.ts diff --git a/apps/browser/src/background/notification.background.ts b/apps/browser/src/background/notification.background.ts index 569a77abe7..64b7ca8a7e 100644 --- a/apps/browser/src/background/notification.background.ts +++ b/apps/browser/src/background/notification.background.ts @@ -394,7 +394,7 @@ export default class NotificationBackground { } const cipher = await this.cipherService.encrypt(model); - await this.cipherService.saveWithServer(cipher); + await this.cipherService.createWithServer(cipher); } private async getDecryptedCipherById(cipherId: string) { @@ -409,7 +409,7 @@ export default class NotificationBackground { if (cipher != null && cipher.type === CipherType.Login) { cipher.login.password = newPassword; const newCipher = await this.cipherService.encrypt(cipher); - await this.cipherService.saveWithServer(newCipher); + await this.cipherService.updateWithServer(newCipher); } } diff --git a/apps/browser/src/popup/vault/add-edit-custom-fields.component.html b/apps/browser/src/popup/vault/add-edit-custom-fields.component.html index def0af3003..8464655c20 100644 --- a/apps/browser/src/popup/vault/add-edit-custom-fields.component.html +++ b/apps/browser/src/popup/vault/add-edit-custom-fields.component.html @@ -19,6 +19,7 @@ appStopClick (click)="removeField(f)" appA11yTitle="{{ 'remove' | i18n }}" + *ngIf="!(!cipher.edit && editMode)" > @@ -33,6 +34,7 @@ class="row-label" placeholder="{{ 'name' | i18n }}" appInputVerbatim + [readonly]="!cipher.edit && editMode" /> +
@@ -44,6 +50,7 @@ [(ngModel)]="cipher.login.username" inputmode="email" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -53,6 +60,7 @@ appStopClick appA11yTitle="{{ 'generateUsername' | i18n }}" (click)="generateUsername()" + *ngIf="!(!cipher.edit && editMode)" > @@ -69,6 +77,7 @@ [(ngModel)]="cipher.login.password" appInputVerbatim [disabled]="!cipher.viewPassword" + [readonly]="!cipher.edit && editMode" />
@@ -114,7 +123,7 @@ appStopClick appA11yTitle="{{ 'generatePassword' | i18n }}" (click)="generatePassword()" - *ngIf="cipher.viewPassword" + *ngIf="cipher.viewPassword && !(!cipher.edit && editMode)" > @@ -130,6 +139,7 @@ [(ngModel)]="cipher.login.totp" appInputVerbatim [disabled]="!cipher.viewPassword" + [readonly]="!cipher.edit && editMode" />
@@ -142,6 +152,7 @@ type="text" name="Card.CardCardholderName" [(ngModel)]="cipher.card.cardholderName" + [readonly]="!cipher.edit && editMode" />
@@ -154,6 +165,7 @@ name="Card.Number" [(ngModel)]="cipher.card.number" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -175,17 +187,39 @@
- + + + + + +
- + + + + + +
@@ -195,6 +229,7 @@ name="Card.ExpYear" [(ngModel)]="cipher.card.expYear" placeholder="{{ 'ex' | i18n }} {{ currentDate | date: 'yyyy' }}" + [readonly]="!cipher.edit && editMode" />
@@ -207,6 +242,7 @@ name="Card.Code" [(ngModel)]="cipher.card.code" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -231,11 +267,22 @@
- + + + + + +
@@ -244,6 +291,7 @@ type="text" name="Identity.FirstName" [(ngModel)]="cipher.identity.firstName" + [readonly]="!cipher.edit && editMode" />
@@ -253,6 +301,7 @@ type="text" name="Identity.MiddleName" [(ngModel)]="cipher.identity.middleName" + [readonly]="!cipher.edit && editMode" />
@@ -262,6 +311,7 @@ type="text" name="Identity.LastName" [(ngModel)]="cipher.identity.lastName" + [readonly]="!cipher.edit && editMode" />
@@ -272,6 +322,7 @@ name="Identity.Username" [(ngModel)]="cipher.identity.username" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -281,6 +332,7 @@ type="text" name="Identity.Company" [(ngModel)]="cipher.identity.company" + [readonly]="!cipher.edit && editMode" />
@@ -291,6 +343,7 @@ name="Identity.SSN" [(ngModel)]="cipher.identity.ssn" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -301,6 +354,7 @@ name="Identity.PassportNumber" [(ngModel)]="cipher.identity.passportNumber" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -311,6 +365,7 @@ name="Identity.LicenseNumber" [(ngModel)]="cipher.identity.licenseNumber" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -321,6 +376,7 @@ name="Identity.Email" [(ngModel)]="cipher.identity.email" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -330,6 +386,7 @@ type="text" name="Identity.Phone" [(ngModel)]="cipher.identity.phone" + [readonly]="!cipher.edit && editMode" />
@@ -339,6 +396,7 @@ type="text" name="Identity.Address1" [(ngModel)]="cipher.identity.address1" + [readonly]="!cipher.edit && editMode" />
@@ -348,6 +406,7 @@ type="text" name="Identity.Address2" [(ngModel)]="cipher.identity.address2" + [readonly]="!cipher.edit && editMode" />
@@ -357,6 +416,7 @@ type="text" name="Identity.Address3" [(ngModel)]="cipher.identity.address3" + [readonly]="!cipher.edit && editMode" />
@@ -366,6 +426,7 @@ type="text" name="Identity.City" [(ngModel)]="cipher.identity.city" + [readonly]="!cipher.edit && editMode" />
@@ -375,6 +436,7 @@ type="text" name="Identity.State" [(ngModel)]="cipher.identity.state" + [readonly]="!cipher.edit && editMode" />
@@ -384,6 +446,7 @@ type="text" name="Identity.PostalCode" [(ngModel)]="cipher.identity.postalCode" + [readonly]="!cipher.edit && editMode" />
@@ -393,6 +456,7 @@ type="text" name="Identity.Country" [(ngModel)]="cipher.identity.country" + [readonly]="!cipher.edit && editMode" />
@@ -484,6 +548,7 @@ appStopClick (click)="addUri()" class="box-content-row box-content-row-newmulti" + *ngIf="!(!cipher.edit && editMode)" > {{ "newUri" | i18n }} @@ -535,6 +600,7 @@ name="PasswordPrompt" [ngModel]="reprompt" (change)="repromptChanged()" + [disabled]="!cipher.edit && editMode" />
- @@ -31,6 +32,7 @@ class="row-label" placeholder="{{ 'name' | i18n }}" appInputVerbatim + [readonly]="!cipher.edit && editMode" /> - - + + + + + +
- + + + + + +
@@ -184,6 +216,7 @@ name="Card.ExpYear" [(ngModel)]="cipher.card.expYear" placeholder="{{ 'ex' | i18n }} {{ currentDate | date: 'yyyy' }}" + [readonly]="!cipher.edit && editMode" />
@@ -196,6 +229,7 @@ name="Card.Code" [(ngModel)]="cipher.card.code" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -220,11 +254,22 @@
- + + + + + +
@@ -233,6 +278,7 @@ type="text" name="Identity.FirstName" [(ngModel)]="cipher.identity.firstName" + [readonly]="!cipher.edit && editMode" />
@@ -242,6 +288,7 @@ type="text" name="Identity.MiddleName" [(ngModel)]="cipher.identity.middleName" + [readonly]="!cipher.edit && editMode" />
@@ -251,6 +298,7 @@ type="text" name="Identity.LastName" [(ngModel)]="cipher.identity.lastName" + [readonly]="!cipher.edit && editMode" />
@@ -261,6 +309,7 @@ name="Identity.Username" [(ngModel)]="cipher.identity.username" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -270,6 +319,7 @@ type="text" name="Identity.Company" [(ngModel)]="cipher.identity.company" + [readonly]="!cipher.edit && editMode" />
@@ -280,6 +330,7 @@ name="Identity.SSN" [(ngModel)]="cipher.identity.ssn" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -290,6 +341,7 @@ name="Identity.PassportNumber" [(ngModel)]="cipher.identity.passportNumber" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -300,6 +352,7 @@ name="Identity.LicenseNumber" [(ngModel)]="cipher.identity.licenseNumber" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -310,6 +363,7 @@ name="Identity.Email" [(ngModel)]="cipher.identity.email" appInputVerbatim + [readonly]="!cipher.edit && editMode" />
@@ -319,6 +373,7 @@ type="text" name="Identity.Phone" [(ngModel)]="cipher.identity.phone" + [readonly]="!cipher.edit && editMode" />
@@ -328,6 +383,7 @@ type="text" name="Identity.Address1" [(ngModel)]="cipher.identity.address1" + [readonly]="!cipher.edit && editMode" />
@@ -337,6 +393,7 @@ type="text" name="Identity.Address2" [(ngModel)]="cipher.identity.address2" + [readonly]="!cipher.edit && editMode" />
@@ -346,6 +403,7 @@ type="text" name="Identity.Address3" [(ngModel)]="cipher.identity.address3" + [readonly]="!cipher.edit && editMode" />
@@ -355,6 +413,7 @@ type="text" name="Identity.City" [(ngModel)]="cipher.identity.city" + [readonly]="!cipher.edit && editMode" />
@@ -364,6 +423,7 @@ type="text" name="Identity.State" [(ngModel)]="cipher.identity.state" + [readonly]="!cipher.edit && editMode" />
@@ -373,6 +433,7 @@ type="text" name="Identity.PostalCode" [(ngModel)]="cipher.identity.postalCode" + [readonly]="!cipher.edit && editMode" />
@@ -382,6 +443,7 @@ type="text" name="Identity.Country" [(ngModel)]="cipher.identity.country" + [readonly]="!cipher.edit && editMode" />
@@ -402,6 +464,7 @@ appStopClick (click)="removeUri(u)" appA11yTitle="{{ 'remove' | i18n }}" + [disabled]="!cipher.edit && editMode" > @@ -446,7 +509,13 @@
- @@ -481,6 +550,7 @@ name="PasswordPrompt" [ngModel]="reprompt" (change)="repromptChanged()" + [disabled]="!cipher.edit && editMode" /> -
+
@@ -44,6 +45,7 @@ [(ngModel)]="f.value" appInputVerbatim [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" attr.aria-describedby="fieldName{{ i }}" />
@@ -68,6 +70,7 @@ appInputVerbatim autocomplete="new-password" [disabled]="cipher.isDeleted || viewOnly || (!cipher.viewPassword && !f.newField)" + [readonly]="!cipher.edit && editMode" attr.aria-describedby="fieldName{{ i }}" />
@@ -130,7 +133,7 @@ class="btn btn-link text-danger ml-2" (click)="removeField(f)" appA11yTitle="{{ 'remove' | i18n }}" - *ngIf="!cipher.isDeleted && !viewOnly" + *ngIf="!cipher.isDeleted && !viewOnly && !(!cipher.edit && editMode)" > @@ -138,7 +141,7 @@ type="button" class="btn btn-link text-muted cursor-move" appA11yTitle="{{ 'dragToSort' | i18n }}" - *ngIf="!cipher.isDeleted && !viewOnly" + *ngIf="!cipher.isDeleted && !viewOnly && !(!cipher.edit && editMode)" > @@ -152,11 +155,11 @@ appStopClick (click)="addField()" class="d-inline-block mb-2" - *ngIf="!cipher.isDeleted && !viewOnly" + *ngIf="!cipher.isDeleted && !viewOnly && !(!cipher.edit && editMode)" > {{ "newCustomField" | i18n }} -
+
- - + + + + + +
@@ -403,6 +422,7 @@ appInputVerbatim autocomplete="new-password" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -471,6 +504,7 @@ appInputVerbatim autocomplete="new-password" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -526,6 +572,7 @@ name="Identity.FirstName" [(ngModel)]="cipher.identity.firstName" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -537,6 +584,7 @@ name="Identity.MiddleName" [(ngModel)]="cipher.identity.middleName" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -548,6 +596,7 @@ name="Identity.LastName" [(ngModel)]="cipher.identity.lastName" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -562,6 +611,7 @@ [(ngModel)]="cipher.identity.username" appInputVerbatim [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -573,6 +623,7 @@ name="Identity.Company" [(ngModel)]="cipher.identity.company" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -587,6 +638,7 @@ [(ngModel)]="cipher.identity.ssn" appInputVerbatim [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -599,6 +651,7 @@ [(ngModel)]="cipher.identity.passportNumber" appInputVerbatim [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -611,6 +664,7 @@ [(ngModel)]="cipher.identity.licenseNumber" appInputVerbatim [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -626,6 +680,7 @@ [(ngModel)]="cipher.identity.email" appInputVerbatim [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -638,6 +693,7 @@ name="Identity.Phone" [(ngModel)]="cipher.identity.phone" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -651,6 +707,7 @@ name="Identity.Address1" [(ngModel)]="cipher.identity.address1" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -662,6 +719,7 @@ name="Identity.Address2" [(ngModel)]="cipher.identity.address2" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -675,6 +733,7 @@ name="Identity.Address3" [(ngModel)]="cipher.identity.address3" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -686,6 +745,7 @@ name="Identity.City" [(ngModel)]="cipher.identity.city" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -699,6 +759,7 @@ name="Identity.State" [(ngModel)]="cipher.identity.state" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -710,6 +771,7 @@ name="Identity.PostalCode" [(ngModel)]="cipher.identity.postalCode" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" />
@@ -723,6 +785,7 @@ name="Identity.Country" [(ngModel)]="cipher.identity.country" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" /> @@ -735,14 +798,17 @@ rows="6" [(ngModel)]="cipher.notes" [disabled]="cipher.isDeleted || viewOnly" + [readonly]="!cipher.edit && editMode" class="form-control" >

{{ "ownership" | i18n }}

@@ -819,7 +885,7 @@ (change)="repromptChanged()" id="passwordPrompt" name="passwordPrompt" - [disabled]="cipher.isDeleted || viewOnly" + [disabled]="cipher.isDeleted || viewOnly || (!cipher.edit && editMode)" />