Skip to content
Snippets Groups Projects
Commit 41a00fff authored by Mélissa Aïdli's avatar Mélissa Aïdli
Browse files

Syntax in login with get request for charter

parent 7dcdb5f1
No related branches found
No related tags found
1 merge request!80New signup
...@@ -47,6 +47,8 @@ export class LoginComponent implements OnInit { ...@@ -47,6 +47,8 @@ export class LoginComponent implements OnInit {
this.loading = true; this.loading = true;
const { email, password } = this.formGroup.value; const { email, password } = this.formGroup.value;
this.messageService.clear(); this.messageService.clear();
console.log(this.auth.checkFakeSignatureCharter(email))
if (this.auth.checkSignatureCharter(email)){
this.auth.login(email, password).pipe( this.auth.login(email, password).pipe(
catchError(() => { catchError(() => {
this.messageService.error("L'identifiant ou le mot de passe est incorrect."); this.messageService.error("L'identifiant ou le mot de passe est incorrect.");
...@@ -56,16 +58,25 @@ export class LoginComponent implements OnInit { ...@@ -56,16 +58,25 @@ export class LoginComponent implements OnInit {
// Only continue if no error // Only continue if no error
filter(Boolean), filter(Boolean),
// Get redirect URL from the auth service, provided by the auth guard. // Get redirect URL from the auth service, provided by the auth guard.
map(() => { map(() =>this.auth.redirectUrl ? this.auth.redirectUrl : this.defaultRedirectUrl),
if (this.auth.checkSignatureCharter) { tap(() => this.snackBar.open('Connexion réussie !', 'OK', { duration: 2000 })),
this.auth.redirectUrl ? this.auth.redirectUrl : this.defaultRedirectUrl tap((redirectUrl: string) => this.router.navigate([redirectUrl])),
).subscribe();
} }
else { else {
this.auth.redirectUrl ? this.auth.redirectUrl : this.charterUrl this.auth.login(email, password).pipe(
} catchError(() => {
this.messageService.error("L'identifiant ou le mot de passe est incorrect.");
return of(false);
}), }),
tap(() => this.snackBar.open('Connexion réussie !', 'OK', { duration: 2000 })), tap(() => this.loading = false),
// Only continue if no error
filter(Boolean),
// Get redirect URL from the auth service, provided by the auth guard.
map(() =>this.auth.redirectUrl ? this.auth.redirectUrl : this.charterUrl),
tap(() => this.snackBar.open('Connexion réussie ! Tu vas devoir signer des chartes', 'OK', { duration: 2000 })),
tap((redirectUrl: string) => this.router.navigate([redirectUrl])),
).subscribe(); ).subscribe();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment