toggle password visibility on login/register

This commit is contained in:
Kyle Spearrin 2018-02-24 13:45:41 -05:00
parent ccfc7b3eb1
commit 40e135a297
6 changed files with 61 additions and 13 deletions

View File

@ -1,5 +1,5 @@
<div class="modal fade"> <div class="modal fade">
<div class="modal-dialog modal-sm"> <div class="modal-dialog">
<form class="modal-content" (ngSubmit)="submit()"> <form class="modal-content" (ngSubmit)="submit()">
<div class="modal-body"> <div class="modal-body">
<div class="box"> <div class="box">

View File

@ -9,10 +9,19 @@
<input id="email" type="text" name="Email" [(ngModel)]="email" required <input id="email" type="text" name="Email" [(ngModel)]="email" required
[appAutofocus]="email === ''"> [appAutofocus]="email === ''">
</div> </div>
<div class="box-content-row" appBoxRow> <div class="box-content-row box-content-row-flex" appBoxRow>
<div class="row-main">
<label for="masterPassword">{{'masterPass' | i18n}}</label> <label for="masterPassword">{{'masterPass' | i18n}}</label>
<input id="masterPassword" type="password" name="MasterPassword" [(ngModel)]="masterPassword" <input id="masterPassword" type="{{showPassword ? 'text' : 'password'}}" name="MasterPassword"
required [appAutofocus]="email !== ''"> class="monospaced" [(ngModel)]="masterPassword" required [appAutofocus]="email !== ''">
</div>
<div class="action-buttons">
<a class="row-btn" href="#" appStopClick appBlurClick
title="{{'toggleVisibility' | i18n}}" (click)="togglePassword()">
<i class="fa fa-lg"
[ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
</a>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -29,6 +29,7 @@ export class LoginComponent {
email: string = ''; email: string = '';
masterPassword: string = ''; masterPassword: string = '';
showPassword: boolean = false;
formPromise: Promise<AuthResult>; formPromise: Promise<AuthResult>;
constructor(private authService: AuthService, private router: Router, private analytics: Angulartics2, constructor(private authService: AuthService, private router: Router, private analytics: Angulartics2,
@ -76,4 +77,10 @@ export class LoginComponent {
modal.close(); modal.close();
}); });
} }
togglePassword() {
this.analytics.eventTrack.next({ action: 'Toggled Master Password on Login' });
this.showPassword = !this.showPassword;
document.getElementById('masterPassword').focus();
}
} }

View File

@ -8,10 +8,19 @@
<input id="email" type="text" name="Email" [(ngModel)]="email" required <input id="email" type="text" name="Email" [(ngModel)]="email" required
[appAutofocus]="email === ''"> [appAutofocus]="email === ''">
</div> </div>
<div class="box-content-row" appBoxRow> <div class="box-content-row box-content-row-flex" appBoxRow>
<div class="row-main">
<label for="masterPassword">{{'masterPass' | i18n}}</label> <label for="masterPassword">{{'masterPass' | i18n}}</label>
<input id="masterPassword" type="password" name="MasterPassword" [(ngModel)]="masterPassword" <input id="masterPassword" type="{{showPassword ? 'text' : 'password'}}" name="MasterPassword"
required [appAutofocus]="email !== ''"> class="monospaced" [(ngModel)]="masterPassword" required [appAutofocus]="email !== ''">
</div>
<div class="action-buttons">
<a class="row-btn" href="#" appStopClick appBlurClick
title="{{'toggleVisibility' | i18n}}" (click)="togglePassword(false)">
<i class="fa fa-lg"
[ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
</a>
</div>
</div> </div>
</div> </div>
<div class="box-footer"> <div class="box-footer">
@ -20,10 +29,20 @@
</div> </div>
<div class="box last"> <div class="box last">
<div class="box-content"> <div class="box-content">
<div class="box-content-row" appBoxRow> <div class="box-content-row box-content-row-flex" appBoxRow>
<label for="master-password-retype">{{'reTypeMasterPass' | i18n}}</label> <div class="row-main">
<input id="master-password-retype" type="password" name="MasterPasswordRetype" <label for="masterPasswordRetype">{{'reTypeMasterPass' | i18n}}</label>
[(ngModel)]="confirmMasterPassword" required> <input id="masterPasswordRetype" type="{{showPassword ? 'text' : 'password'}}"
name="MasterPasswordRetype" class="monospaced" [(ngModel)]="confirmMasterPassword"
required>
</div>
<div class="action-buttons">
<a class="row-btn" href="#" appStopClick appBlurClick
title="{{'toggleVisibility' | i18n}}" (click)="togglePassword(true)">
<i class="fa fa-lg"
[ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
</a>
</div>
</div> </div>
<div class="box-content-row" appBoxRow> <div class="box-content-row" appBoxRow>
<label for="hint">{{'masterPassHint' | i18n}}</label> <label for="hint">{{'masterPassHint' | i18n}}</label>

View File

@ -22,6 +22,7 @@ export class RegisterComponent {
masterPassword: string = ''; masterPassword: string = '';
confirmMasterPassword: string = ''; confirmMasterPassword: string = '';
hint: string = ''; hint: string = '';
showPassword: boolean = false;
formPromise: Promise<any>; formPromise: Promise<any>;
constructor(private authService: AuthService, private router: Router, private analytics: Angulartics2, constructor(private authService: AuthService, private router: Router, private analytics: Angulartics2,
@ -72,4 +73,10 @@ export class RegisterComponent {
const request = new RegisterRequest(this.email, hashedPassword, this.hint, encKey.encryptedString); const request = new RegisterRequest(this.email, hashedPassword, this.hint, encKey.encryptedString);
await this.apiService.postRegister(request); await this.apiService.postRegister(request);
} }
togglePassword(confirmField: boolean) {
this.analytics.eventTrack.next({ action: 'Toggled Master Password on Register' });
this.showPassword = !this.showPassword;
document.getElementById(confirmField ? 'masterPasswordRetype' : 'masterPassword').focus();
}
} }

View File

@ -110,3 +110,9 @@
} }
} }
} }
#register-page {
.content {
width: 400px;
}
}