Skip to content

Commit

Permalink
[PM-13938] Changes to disabled user from seeing password that they sh…
Browse files Browse the repository at this point in the history
…ouldn'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 <[email protected]>
  • Loading branch information
cd-bitwarden and kejaeger authored Jan 21, 2025
1 parent 007e2fc commit cc7defc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h2 bitTypography="h6">{{ "customFields" | i18n }}</h2>
bitSuffix
bitPasswordInputToggle
data-testid="visibility-for-custom-hidden-field"
[disabled]="!canViewPasswords(i)"
*ngIf="canViewPasswords(i)"
(toggledChange)="logHiddenEvent($event)"
></button>
</bit-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h2 bitTypography="h6">{{ "customFields" | i18n }}</h2>
<button
bitSuffix
type="button"
*ngIf="this.cipher.viewPassword"
bitIconButton
bitPasswordInputToggle
*ngIf="canViewPassword"
Expand All @@ -44,6 +45,7 @@ <h2 bitTypography="h6">{{ "customFields" | i18n }}</h2>
<button
bitIconButton="bwi-clone"
bitSuffix
*ngIf="this.cipher.viewPassword"
type="button"
[appCopyClick]="field.value"
showToast
Expand Down

0 comments on commit cc7defc

Please sign in to comment.