From cc7defc4475bfe237d1fb13b4135a62288def55f Mon Sep 17 00:00:00 2001 From: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com> Date: Tue, 21 Jan 2025 14:50:05 -0500 Subject: [PATCH] [PM-13938] Changes to disabled user from seeing password that they shouldn't see or edit easily. (#12161) * Changes to disabled user from seeing password that they shouldn't see or edit easily. * Fixing defects on PM-13938 * undoing unecessary change * Updating tests --------- Co-authored-by: --global <> Co-authored-by: kejaeger <138028972+kejaeger@users.noreply.github.com> --- .../custom-fields/custom-fields.component.html | 2 +- .../custom-fields.component.spec.ts | 17 +++++++++++++++-- .../custom-fields-v2.component.html | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.html b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.html index 63941c6a46..fab3c8f1ab 100644 --- a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.html +++ b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.html @@ -46,7 +46,7 @@ bitSuffix bitPasswordInputToggle data-testid="visibility-for-custom-hidden-field" - [disabled]="!canViewPasswords(i)" + *ngIf="canViewPasswords(i)" (toggledChange)="logHiddenEvent($event)" > diff --git a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.spec.ts b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.spec.ts index a5e57d2858..b523d9ef93 100644 --- a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.spec.ts +++ b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.spec.ts @@ -113,7 +113,7 @@ describe("CustomFieldsComponent", () => { ]); }); - it("forbids a user to view hidden fields when the cipher `viewPassword` is false", () => { + it("when `viewPassword` is false the user cannot see the view toggle option", () => { originalCipherView.viewPassword = false; originalCipherView.fields = mockFieldViews; @@ -123,7 +123,20 @@ describe("CustomFieldsComponent", () => { const button = fixture.debugElement.query(By.directive(BitPasswordInputToggleDirective)); - expect(button.nativeElement.disabled).toBe(true); + expect(button).toBeFalsy(); + }); + + it("when `viewPassword` is true the user can see the view toggle option", () => { + originalCipherView.viewPassword = true; + originalCipherView.fields = mockFieldViews; + + component.ngOnInit(); + + fixture.detectChanges(); + + const button = fixture.debugElement.query(By.directive(BitPasswordInputToggleDirective)); + + expect(button).toBeTruthy(); }); describe("linkedFieldOptions", () => { diff --git a/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html b/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html index ab31ede57b..8eee79729a 100644 --- a/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html +++ b/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html @@ -36,6 +36,7 @@