diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index e438b48c5d263dcc093e6390b1e4600f2b5c7e1b..dff78f80fd0230cea93101f9cb65c2b4c47dbbf6 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -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(); + } }