Misc changes about form inputs.

This commit is contained in:
Florian THIERRY
2024-10-21 14:40:15 +02:00
committed by Florian THIERRY
parent cfca22bf66
commit 053ac89e3c
14 changed files with 54 additions and 54 deletions

View File

@@ -60,18 +60,24 @@ export class LoginService {
performLogin(): void {
const state = this.state;
// Check state is valid
if (this.isStateValid(state)) {
this.userRestService
.login(state.request)
.then((response) => {
this.authenticationService.authenticate(response.accessToken, response.refreshToken);
this.snackBar.open($localize`Authentication succeeded!`, $localize`Close`, { duration: 5000 });
this.router.navigate(['/home']);
})
.catch((error) => {
console.error(error);
this.snackBar.open($localize`Authentication failed.`, $localize`Close`, { duration: 5000 });
});
} else {
this.snackBar.open($localize`Please, fill the inputs before send.`, $localize`Close`, { duration: 5000 });
}
}
this.userRestService
.login(state.request)
.then((response) => {
this.authenticationService.authenticate(response.accessToken, response.refreshToken);
this.snackBar.open($localize`Authentication succeeded!`, $localize`Close`, { duration: 5000 });
this.router.navigate(['/home']);
})
.catch((error) => {
console.error(error);
this.snackBar.open($localize`Authentication failed.`, $localize`Close`, { duration: 5000 });
});
isStateValid(state: LoginState): boolean {
return !!state.request.email?.trim().length && !!state.request.password?.length;
}
}