frontend: enhance login form with password visibility toggle and improved input handling
This commit is contained in:
parent
e1fd2a343b
commit
a2e78afda5
@ -6,18 +6,40 @@
|
|||||||
<form [formGroup]="loginForm" (ngSubmit)="login()" id="login-form">
|
<form [formGroup]="loginForm" (ngSubmit)="login()" id="login-form">
|
||||||
<mat-form-field class="form-input" appearance="fill">
|
<mat-form-field class="form-input" appearance="fill">
|
||||||
<mat-label>Username</mat-label>
|
<mat-label>Username</mat-label>
|
||||||
<input matInput formControlName="username" required id="username-input" />
|
<input matInput formControlName="username" placeholder="Enter your username" id="username-input" />
|
||||||
<mat-icon matPrefix>person</mat-icon>
|
<mat-icon matPrefix>person</mat-icon>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field class="form-input" appearance="fill">
|
<mat-form-field class="form-input" appearance="fill">
|
||||||
<mat-label>Password</mat-label>
|
<mat-label>Password</mat-label>
|
||||||
<input matInput type="password" formControlName="password" required id="password-input" />
|
<input
|
||||||
|
matInput
|
||||||
|
[type]="showPassword ? 'text' : 'password'"
|
||||||
|
formControlName="password"
|
||||||
|
placeholder="Enter your password"
|
||||||
|
id="password-input"
|
||||||
|
/>
|
||||||
<mat-icon matPrefix>lock</mat-icon>
|
<mat-icon matPrefix>lock</mat-icon>
|
||||||
|
<button
|
||||||
|
mat-icon-button
|
||||||
|
matSuffix
|
||||||
|
type="button"
|
||||||
|
class="input-btn"
|
||||||
|
(click)="showPassword = !showPassword"
|
||||||
|
matTooltip="{{ showPassword ? 'Hide password' : 'Show password' }}"
|
||||||
|
>
|
||||||
|
<mat-icon>{{ showPassword ? 'visibility_off' : 'visibility' }}</mat-icon>
|
||||||
|
</button>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<div class="login-button">
|
<div class="login-button">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="loginForm.invalid" id="login-button">
|
<button
|
||||||
|
mat-raised-button
|
||||||
|
color="primary"
|
||||||
|
type="submit"
|
||||||
|
[disabled]="loginForm.invalid"
|
||||||
|
id="login-button"
|
||||||
|
>
|
||||||
Login
|
Login
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { MatCardModule } from '@angular/material/card';
|
|||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
import { ActivatedRoute, RouterModule } from '@angular/router';
|
import { ActivatedRoute, RouterModule } from '@angular/router';
|
||||||
import { AuthService, NavigationService } from '@lib/services';
|
import { AuthService, NavigationService } from '@lib/services';
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ import { AuthService, NavigationService } from '@lib/services';
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
MatCardModule,
|
MatCardModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
|
MatTooltipModule,
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
templateUrl: './login.component.html',
|
templateUrl: './login.component.html',
|
||||||
@ -27,10 +29,13 @@ import { AuthService, NavigationService } from '@lib/services';
|
|||||||
})
|
})
|
||||||
export class LoginComponent implements OnInit {
|
export class LoginComponent implements OnInit {
|
||||||
loginForm = new FormGroup({
|
loginForm = new FormGroup({
|
||||||
username: new FormControl('', [Validators.required, Validators.minLength(4)]),
|
username: new FormControl('', [Validators.required]),
|
||||||
password: new FormControl('', [Validators.required, Validators.minLength(4)])
|
password: new FormControl('', [Validators.required])
|
||||||
});
|
});
|
||||||
|
|
||||||
|
showPassword = false;
|
||||||
loginErrorMessage: string | undefined;
|
loginErrorMessage: string | undefined;
|
||||||
|
|
||||||
redirectTo = ''; // By default, redirect to home page
|
redirectTo = ''; // By default, redirect to home page
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user