Skip to content
Snippets Groups Projects

New signup

Merged Hamza Touizrat requested to merge new_signup into master
+ 31
20
@@ -47,25 +47,36 @@ export class LoginComponent implements OnInit {
this.loading = true;
const { email, password } = this.formGroup.value;
this.messageService.clear();
this.auth.login(email, password).pipe(
catchError(() => {
this.messageService.error("L'identifiant ou le mot de passe est incorrect.");
return of(false);
}),
tap(() => this.loading = false),
// Only continue if no error
filter(Boolean),
// Get redirect URL from the auth service, provided by the auth guard.
map(() => {
if (this.auth.checkSignatureCharter) {
this.auth.redirectUrl ? this.auth.redirectUrl : this.defaultRedirectUrl
}
else {
this.auth.redirectUrl ? this.auth.redirectUrl : this.charterUrl
}
}),
tap(() => this.snackBar.open('Connexion réussie !', 'OK', { duration: 2000 })),
).subscribe();
}
console.log(this.auth.checkFakeSignatureCharter(email))
if (this.auth.checkSignatureCharter(email)){
this.auth.login(email, password).pipe(
catchError(() => {
this.messageService.error("L'identifiant ou le mot de passe est incorrect.");
return of(false);
}),
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.defaultRedirectUrl),
tap(() => this.snackBar.open('Connexion réussie !', 'OK', { duration: 2000 })),
tap((redirectUrl: string) => this.router.navigate([redirectUrl])),
).subscribe();
}
else {
this.auth.login(email, password).pipe(
catchError(() => {
this.messageService.error("L'identifiant ou le mot de passe est incorrect.");
return of(false);
}),
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();
}
}
Loading