1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-02 08:40:08 +01:00

Merge pull request #1249 from Hinton/feature/hidden-password

Add support for hidden password
This commit is contained in:
Chad Scharf 2020-06-11 15:01:37 -04:00 committed by GitHub
commit 25a86608b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 16 deletions

2
jslib

@ -1 +1 @@
Subproject commit eef9588646091d268ef4c94f3d6db1412d9a99ab Subproject commit 2b6657a293e7be107271ad080c64ccd3f005afb7

View File

@ -579,7 +579,7 @@ export default class MainBackground {
}); });
} }
if (cipher == null || (cipher.login.password && cipher.login.password !== '')) { if (cipher == null || (cipher.login.password && cipher.login.password !== '' && cipher.viewPassword)) {
await this.contextMenusCreate({ await this.contextMenusCreate({
type: 'normal', type: 'normal',
id: 'copy-password_' + idSuffix, id: 'copy-password_' + idSuffix,

View File

@ -13,7 +13,7 @@
</span> </span>
<span class="row-btn" appStopClick appStopProp appA11yTitle="{{'copyPassword' | i18n}}" <span class="row-btn" appStopClick appStopProp appA11yTitle="{{'copyPassword' | i18n}}"
(click)="copy(cipher, cipher.login.password, 'password', 'Password')" (click)="copy(cipher, cipher.login.password, 'password', 'Password')"
[ngClass]="{disabled: !cipher.login.password}"> [ngClass]="{disabled: (!cipher.login.password || !cipher.viewPassword)}">
<i class="fa fa-lg fa-key" aria-hidden="true"></i> <i class="fa fa-lg fa-key" aria-hidden="true"></i>
</span> </span>
</ng-container> </ng-container>

View File

@ -53,6 +53,10 @@ export class ActionButtonsComponent {
return; return;
} }
if (!cipher.viewPassword) {
return;
}
this.analytics.eventTrack.next({ action: 'Copied ' + aType }); this.analytics.eventTrack.next({ action: 'Copied ' + aType });
this.platformUtilsService.copyToClipboard(value, { window: window }); this.platformUtilsService.copyToClipboard(value, { window: window });
this.toasterService.popAsync('info', null, this.toasterService.popAsync('info', null,

View File

@ -40,32 +40,36 @@
<div class="row-main"> <div class="row-main">
<label for="loginPassword">{{'password' | i18n}}</label> <label for="loginPassword">{{'password' | i18n}}</label>
<input id="loginPassword" class="monospaced" type="{{showPassword ? 'text' : 'password'}}" <input id="loginPassword" class="monospaced" type="{{showPassword ? 'text' : 'password'}}"
name="Login.Password" [(ngModel)]="cipher.login.password" appInputVerbatim> name="Login.Password" [(ngModel)]="cipher.login.password" appInputVerbatim
[disabled]="!cipher.viewPassword">
</div> </div>
<div class="action-buttons"> <div class="action-buttons">
<button type="button" #checkPasswordBtn class="row-btn btn" appBlurClick <button type="button" #checkPasswordBtn class="row-btn btn" appBlurClick
appA11yTitle="{{'checkPassword' | i18n}}" (click)="checkPassword()" appA11yTitle="{{'checkPassword' | i18n}}" (click)="checkPassword()"
[appApiAction]="checkPasswordPromise" [disabled]="checkPasswordBtn.loading"> [appApiAction]="checkPasswordPromise" [disabled]="checkPasswordBtn.loading"
*ngIf="cipher.viewPassword">
<i class="fa fa-lg fa-check-circle" [hidden]="checkPasswordBtn.loading" <i class="fa fa-lg fa-check-circle" [hidden]="checkPasswordBtn.loading"
aria-hidden="true"></i> aria-hidden="true"></i>
<i class="fa fa-lg fa-spinner fa-spin" [hidden]="!checkPasswordBtn.loading" <i class="fa fa-lg fa-spinner fa-spin" [hidden]="!checkPasswordBtn.loading"
aria-hidden="true"></i> aria-hidden="true"></i>
</button> </button>
<a class="row-btn" href="#" appStopClick appBlurClick <a class="row-btn" href="#" appStopClick appBlurClick
appA11yTitle="{{'toggleVisibility' | i18n}}" (click)="togglePassword()"> appA11yTitle="{{'toggleVisibility' | i18n}}" (click)="togglePassword()"
*ngIf="cipher.viewPassword">
<i class="fa fa-lg" aria-hidden="true" <i class="fa fa-lg" aria-hidden="true"
[ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i> [ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
</a> </a>
<a class="row-btn" href="#" appStopClick appBlurClick <a class="row-btn" href="#" appStopClick appBlurClick
appA11yTitle="{{'generatePassword' | i18n}}" (click)="generatePassword()"> appA11yTitle="{{'generatePassword' | i18n}}" (click)="generatePassword()"
*ngIf="cipher.viewPassword">
<i class="fa fa-lg fa-refresh" aria-hidden="true"></i> <i class="fa fa-lg fa-refresh" aria-hidden="true"></i>
</a> </a>
</div> </div>
</div> </div>
<div class="box-content-row" appBoxRow> <div class="box-content-row" appBoxRow>
<label for="loginTotp">{{'authenticatorKeyTotp' | i18n}}</label> <label for="loginTotp">{{'authenticatorKeyTotp' | i18n}}</label>
<input id="loginTotp" type="text" name="Login.Totp" class="monospaced" <input id="loginTotp" type="{{cipher.viewPassword ? 'text' : 'password'}}" name="Login.Totp"
[(ngModel)]="cipher.login.totp" appInputVerbatim> class="monospaced" [(ngModel)]="cipher.login.totp" appInputVerbatim [disabled]="!cipher.viewPassword">
</div> </div>
</div> </div>
<!-- Card --> <!-- Card -->
@ -293,11 +297,13 @@
*ngIf="f.type === fieldType.Text" placeholder="{{'value' | i18n}}" appInputVerbatim> *ngIf="f.type === fieldType.Text" placeholder="{{'value' | i18n}}" appInputVerbatim>
<input id="fieldValue{{i}}" type="{{f.showValue ? 'text' : 'password'}}" <input id="fieldValue{{i}}" type="{{f.showValue ? 'text' : 'password'}}"
name="Field.Value{{i}}" [(ngModel)]="f.value" class="monospaced" appInputVerbatim name="Field.Value{{i}}" [(ngModel)]="f.value" class="monospaced" appInputVerbatim
*ngIf="f.type === fieldType.Hidden" placeholder="{{'value' | i18n}}"> *ngIf="f.type === fieldType.Hidden" placeholder="{{'value' | i18n}}"
[disabled]="!cipher.viewPassword && !f.newField">
</div> </div>
<input id="fieldValue{{i}}" name="Field.Value{{i}}" type="checkbox" [(ngModel)]="f.value" <input id="fieldValue{{i}}" name="Field.Value{{i}}" type="checkbox" [(ngModel)]="f.value"
*ngIf="f.type === fieldType.Boolean" appTrueFalseValue trueValue="true" falseValue="false"> *ngIf="f.type === fieldType.Boolean" appTrueFalseValue trueValue="true" falseValue="false">
<div class="action-buttons" *ngIf="f.type === fieldType.Hidden"> <div class="action-buttons"
*ngIf="f.type === fieldType.Hidden && (cipher.viewPassword || f.newField)">
<a class="row-btn" href="#" appStopClick appBlurClick <a class="row-btn" href="#" appStopClick appBlurClick
appA11yTitle="{{'toggleVisibility' | i18n}}" (click)="toggleFieldValue(f)"> appA11yTitle="{{'toggleVisibility' | i18n}}" (click)="toggleFieldValue(f)">
<i class="fa fa-lg" aria-hidden="true" <i class="fa fa-lg" aria-hidden="true"

View File

@ -46,19 +46,21 @@
<div class="action-buttons"> <div class="action-buttons">
<button type="button" #checkPasswordBtn class="row-btn btn" appBlurClick <button type="button" #checkPasswordBtn class="row-btn btn" appBlurClick
appA11yTitle="{{'checkPassword' | i18n}}" (click)="checkPassword()" appA11yTitle="{{'checkPassword' | i18n}}" (click)="checkPassword()"
[appApiAction]="checkPasswordPromise" [disabled]="checkPasswordBtn.loading"> [appApiAction]="checkPasswordPromise" [disabled]="checkPasswordBtn.loading"
*ngIf="cipher.viewPassword">
<i class="fa fa-lg fa-check-circle" [hidden]="checkPasswordBtn.loading" <i class="fa fa-lg fa-check-circle" [hidden]="checkPasswordBtn.loading"
aria-hidden="true"></i> aria-hidden="true"></i>
<i class="fa fa-lg fa-spinner fa-spin" [hidden]="!checkPasswordBtn.loading" <i class="fa fa-lg fa-spinner fa-spin" [hidden]="!checkPasswordBtn.loading"
aria-hidden="true"></i> aria-hidden="true"></i>
</button> </button>
<a class="row-btn" href="#" appStopClick appA11yTitle="{{'toggleVisibility' | i18n}}" <a class="row-btn" href="#" appStopClick appA11yTitle="{{'toggleVisibility' | i18n}}"
(click)="togglePassword()"> (click)="togglePassword()" *ngIf="cipher.viewPassword">
<i class="fa fa-lg" aria-hidden="true" <i class="fa fa-lg" aria-hidden="true"
[ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i> [ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
</a> </a>
<a class="row-btn" href="#" appStopClick appA11yTitle="{{'copyPassword' | i18n}}" <a class="row-btn" href="#" appStopClick appA11yTitle="{{'copyPassword' | i18n}}"
(click)="copy(cipher.login.password, 'password', 'Password')"> (click)="copy(cipher.login.password, 'password', 'Password')"
*ngIf="cipher.viewPassword">
<i class="fa fa-lg fa-clipboard" aria-hidden="true"></i> <i class="fa fa-lg fa-clipboard" aria-hidden="true"></i>
</a> </a>
</div> </div>
@ -231,12 +233,12 @@
</div> </div>
<div class="action-buttons"> <div class="action-buttons">
<a class="row-btn" href="#" appStopClick appA11yTitle="{{'toggleVisibility' | i18n}}" <a class="row-btn" href="#" appStopClick appA11yTitle="{{'toggleVisibility' | i18n}}"
*ngIf="field.type === fieldType.Hidden" (click)="toggleFieldValue(field)"> *ngIf="field.type === fieldType.Hidden && cipher.viewPassword" (click)="toggleFieldValue(field)">
<i class="fa fa-lg" aria-hidden="true" <i class="fa fa-lg" aria-hidden="true"
[ngClass]="{'fa-eye': !field.showValue, 'fa-eye-slash': field.showValue}"></i> [ngClass]="{'fa-eye': !field.showValue, 'fa-eye-slash': field.showValue}"></i>
</a> </a>
<a class="row-btn" href="#" appStopClick appA11yTitle="{{'copyValue' | i18n}}" <a class="row-btn" href="#" appStopClick appA11yTitle="{{'copyValue' | i18n}}"
*ngIf="field.value && field.type !== fieldType.Boolean" *ngIf="field.value && field.type !== fieldType.Boolean && !(field.type === fieldType.Hidden && !cipher.viewPassword)"
(click)="copy(field.value, 'value', field.type === fieldType.Hidden ? 'H_Field' : 'Field')"> (click)="copy(field.value, 'value', field.type === fieldType.Hidden ? 'H_Field' : 'Field')">
<i class="fa fa-lg fa-clipboard" aria-hidden="true"></i> <i class="fa fa-lg fa-clipboard" aria-hidden="true"></i>
</a> </a>