diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index e7c506f92a021ccc02772f55aaef1367b4bca067..c80551d9b47142168b7e0778089a7bdd03968412 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -18,9 +18,10 @@ class StoredToken extends SimpleStoredItem { key = 'oser-cs-user-token'; } }) export class AuthService { - private loginUrl = environment.apiUrl + 'auth/get-token/'; + private loginUrl = environment. + 'auth/get-token/'; private resetUrl = environment.apiUrl + 'rest-auth/password/reset/'; private resetConfirmUrl = environment.apiUrl + 'rest-auth/password/reset/confirm/'; + private mandatorySignatureUrl = environment.apiUrl + ''; fromGuard: boolean; redirectUrl: string; @@ -82,6 +83,12 @@ export class AuthService { return new HttpHeaders({ Authorization: 'Token ' + this.getToken() }); } + checkSignatureCharter(email: string) : Observable<boolean> { + return this.http.post<any>(this.mandatorySignatureUrl, {email : email}).pipe( + map(() => true), + ); + } + get isLoggedIn(): boolean { if (this.user.get()) { return true; diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 5070b7c97539b16b023d027162da709e04c7cd01..e438b48c5d263dcc093e6390b1e4600f2b5c7e1b 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -15,6 +15,7 @@ export class LoginComponent implements OnInit { loading: boolean = false; defaultRedirectUrl: string = '/membres'; + charterUrl : string = 'inscription/student-charter'; formGroup: FormGroup; constructor( @@ -54,11 +55,17 @@ export class LoginComponent implements OnInit { 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), + // 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 })), - tap((redirectUrl: string) => this.router.navigate([redirectUrl])), ).subscribe(); - } + } } diff --git a/src/app/signup/valid-email/valid-email.component.html b/src/app/signup/valid-email/valid-email.component.html index fbf1fc38b81eb125a175de21ed933eca3e2f8034..a126e50a24ac480910cc9d387736abd0619920c3 100644 --- a/src/app/signup/valid-email/valid-email.component.html +++ b/src/app/signup/valid-email/valid-email.component.html @@ -7,10 +7,8 @@ </p> <div class="text-center"> - <button mat-raised-button color="primary" > - <a routerLink='/inscription/student-charter'> + <button mat-raised-button color="primary" routerLink='/inscription/student-charter' > Suivant - </a> </button> </div> </app-form-page>