Skip to content
Snippets Groups Projects
Commit 2c56b0c9 authored by Hamza Touizrat's avatar Hamza Touizrat
Browse files

Merge branch 'new_signup' into 'master'

add

See merge request !81
parents c5b10345 be8fc32c
Branches
No related tags found
1 merge request!81add
...@@ -18,7 +18,7 @@ export class LoginComponent implements OnInit { ...@@ -18,7 +18,7 @@ export class LoginComponent implements OnInit {
defaultRedirectUrl: string = '/membres'; defaultRedirectUrl: string = '/membres';
charterUrl: string = 'inscription/student-charter'; charterUrl: string = 'inscription/student-charter';
formGroup: FormGroup; formGroup: FormGroup;
loginSuccess: boolean = false; loginSuccess: boolean = true;
constructor( constructor(
private router: Router, private router: Router,
...@@ -50,43 +50,31 @@ export class LoginComponent implements OnInit { ...@@ -50,43 +50,31 @@ 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();
await this.auth.login(email, password).pipe(
map(() => this.loginSuccess = true), await this.auth.checkSignatureCharter(email).pipe(
catchError(() => { catchError(() => {
this.messageService.error("L'identifiant ou le mot de passe est incorrect."); this.hassignedCharter = false;
this.loginSuccess = false;
return of(false); return of(false);
}), }),
tap(() => this.loading = false), map(() => this.loginSuccess = true),
// Only continue if no error ).toPromise();
filter(Boolean),
// Get redirect URL from the auth service, provided by the auth guard.
).subscribe({ await this.auth.login(email, password).toPromise().catch(() => {
complete() { console.log("this.loginSuccess)");
console.log("login unsuccess");
},
});
this.messageService.error("L'identifiant ou le mot de passe est incorrect.");
tap(() => this.snackBar.open("L'identifiant ou le mot de passe est incorrect.", 'OK', { duration: 2000 })),
if(this.loginSuccess == true){ this.loginSuccess = false;
this.loading = false;
return of(false);
});
this.auth.checkSignatureCharter(email).pipe( if (this.loginSuccess ) {
catchError(() => {
this.hassignedCharter = false;
this.messageService.error("Vous n'avez pas signé le(s) charte(s)."); this.loading = false;
map(() => this.auth.redirectUrl ? this.auth.redirectUrl : this.defaultRedirectUrl), console.log(this.loginSuccess);
tap((redirectUrl: string) => this.router.navigate([redirectUrl]));
return of(false);
}),
map(() => this.auth.redirectUrl ? this.auth.redirectUrl : this.defaultRedirectUrl),
tap(() => this.snackBar.open('Connexion réussie !', 'OK', { duration: 2000 })),
).subscribe().add(() =>
{
if(this.hassignedCharter == false) if(this.hassignedCharter == false)
{ {
this.router.navigate([this.charterUrl]); this.router.navigate([this.charterUrl]);
...@@ -95,8 +83,6 @@ export class LoginComponent implements OnInit { ...@@ -95,8 +83,6 @@ export class LoginComponent implements OnInit {
{ {
this.router.navigate([this.defaultRedirectUrl]); this.router.navigate([this.defaultRedirectUrl]);
} }
});
} }
} }}
} \ No newline at end of file
\ No newline at end of file
...@@ -33,12 +33,12 @@ ...@@ -33,12 +33,12 @@
<!-- <mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput type="tel" minlength="10" maxlength="10" formControlName="phoneNumber" placeholder="Numéro de téléphone" required> <input matInput type="tel" minlength="10" maxlength="10" formControlName="phoneNumber" placeholder="Numéro de téléphone" required>
<mat-hint> <mat-hint>
Il nous permettra de te contacter en cas de nécessité. Il nous permettra de te contacter en cas de nécessité.
</mat-hint> </mat-hint>
</mat-form-field> --> </mat-form-field>
<p> <p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment