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,32 +1,30 @@
<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"
<input matInput [(ngModel)]="loginObj.username" name="username" required #usernameInput="ngModel" [ngClass]="{'invalid': !usernameInput.valid && usernameInput.touched}" /> [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 <mat-icon>{{hide() ? 'visibility_off' : 'visibility'}}</mat-icon>
(click)="clickEvent()" </button>
[attr.aria-label]="'Ocultar contraseña'"
> </mat-form-field>
<mat-icon>{{hide() ? 'visibility_off' : 'visibility'}}</mat-icon> <div class="button-row">
</button> <button mat-flat-button color="primary" type="submit" [disabled]="!loginObj.username || !loginObj.password"
</mat-form-field> i18n="@@buttonLogin">Iniciar sesión</button>
<div class="button-row"> </div>
<button mat-flat-button color="primary" type="submit" [disabled]="!loginObj.username || !loginObj.password" i18n="@@buttonLogin">Iniciar sesión</button>
</div>
</form> </form>
</div> </div>
<!-- BORRAR DESPUES DE LA DEMO --> <!-- BORRAR DESPUES DE LA DEMO -->
<button mat-flat-button (click)="redirectToUrl1()">Español</button> <button mat-flat-button (click)="redirectToUrl1()">Español</button>
<!-- Botón para redirigir a http://localhost:4200/auth/login --> <!-- Botón para redirigir a http://localhost:4200/auth/login -->
<button mat-flat-button (click)="redirectToUrl2()">Inglés</button> <button mat-flat-button (click)="redirectToUrl2()">Inglés</button>

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());
} }