Login - show password bug fix

oggui/translations
Alvaro Puente Mella 2024-10-28 12:28:57 +01:00
parent 742a9ad72b
commit 852f894605
2 changed files with 24 additions and 26 deletions

View File

@ -1,26 +1,24 @@
<div> <div>
<form class="login" (ngSubmit)="onLogin()" #loginForm="ngForm" (keydown.enter)="onLogin()"> <form class="login" (ngSubmit)="onLogin()" #loginForm="ngForm" (keydown.enter)="onLogin()">
<img src="assets/images/logo.png" alt="Opengnsys" <img src="assets/images/logo.png" alt="Opengnsys" class="login-logo" [class.rotating]="isLoading">
class="login-logo" [class.rotating]="isLoading">
<h2 i18n="@@headerOpengnsys">Opengnsys</h2> <h2 i18n="@@headerOpengnsys">Opengnsys</h2>
<mat-form-field> <mat-form-field>
<mat-label i18n="@@loginlabelUsername">Introduce tu usuario</mat-label> <mat-label i18n="@@loginlabelUsername">Introduce tu usuario</mat-label>
<input matInput [(ngModel)]="loginObj.username" name="username" required #usernameInput="ngModel" [ngClass]="{'invalid': !usernameInput.valid && usernameInput.touched}" /> <input matInput [(ngModel)]="loginObj.username" name="username" required #usernameInput="ngModel"
[ngClass]="{'invalid': !usernameInput.valid && usernameInput.touched}" />
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label i18n="@@loginlabelPassword">Introduce tu contraseña</mat-label> <mat-label i18n="@@loginlabelPassword">Introduce tu contraseña</mat-label>
<input matInput (keydown.enter)="$event.preventDefault()" [type]="hide() ? 'password' : 'text'" required [(ngModel)]="loginObj.password" name="password"/> <input matInput (keydown.enter)="$event.preventDefault()" [type]="hide() ? 'password' : 'text'" required
<button [(ngModel)]="loginObj.password" name="password" />
mat-icon-button <button mat-icon-button matSuffix (click)="clickEvent($event)" [attr.aria-label]="'Ocultar contraseña'">
matSuffix
(click)="clickEvent()"
[attr.aria-label]="'Ocultar contraseña'"
>
<mat-icon>{{hide() ? 'visibility_off' : 'visibility'}}</mat-icon> <mat-icon>{{hide() ? 'visibility_off' : 'visibility'}}</mat-icon>
</button> </button>
</mat-form-field> </mat-form-field>
<div class="button-row"> <div class="button-row">
<button mat-flat-button color="primary" type="submit" [disabled]="!loginObj.username || !loginObj.password" i18n="@@buttonLogin">Iniciar sesión</button> <button mat-flat-button color="primary" type="submit" [disabled]="!loginObj.username || !loginObj.password"
i18n="@@buttonLogin">Iniciar sesión</button>
</div> </div>
</form> </form>

View File

@ -45,7 +45,6 @@ export class LoginComponent {
return; return;
} }
// Usar la URL base de la variable de entorno
this.http.post(`${this.baseUrl}/auth/login`, this.loginObj).subscribe({ this.http.post(`${this.baseUrl}/auth/login`, this.loginObj).subscribe({
next: (res: any) => { next: (res: any) => {
if (res.token) { if (res.token) {
@ -65,7 +64,8 @@ export class LoginComponent {
} }
hide = signal(true); hide = signal(true);
clickEvent() { clickEvent(event: Event) {
event.stopPropagation();
this.hide.set(!this.hide()); this.hide.set(!this.hide());
} }