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

Changed the route in login according to charter signature

parent e6eac6d5
Branches
No related tags found
1 merge request!80New signup
...@@ -18,9 +18,10 @@ class StoredToken extends SimpleStoredItem { key = 'oser-cs-user-token'; } ...@@ -18,9 +18,10 @@ class StoredToken extends SimpleStoredItem { key = 'oser-cs-user-token'; }
}) })
export class AuthService { 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 resetUrl = environment.apiUrl + 'rest-auth/password/reset/';
private resetConfirmUrl = environment.apiUrl + 'rest-auth/password/reset/confirm/'; private resetConfirmUrl = environment.apiUrl + 'rest-auth/password/reset/confirm/';
private mandatorySignatureUrl = environment.apiUrl + '';
fromGuard: boolean; fromGuard: boolean;
redirectUrl: string; redirectUrl: string;
...@@ -82,6 +83,12 @@ export class AuthService { ...@@ -82,6 +83,12 @@ export class AuthService {
return new HttpHeaders({ Authorization: 'Token ' + this.getToken() }); 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 { get isLoggedIn(): boolean {
if (this.user.get()) { if (this.user.get()) {
return true; return true;
......
...@@ -15,6 +15,7 @@ export class LoginComponent implements OnInit { ...@@ -15,6 +15,7 @@ export class LoginComponent implements OnInit {
loading: boolean = false; loading: boolean = false;
defaultRedirectUrl: string = '/membres'; defaultRedirectUrl: string = '/membres';
charterUrl : string = 'inscription/student-charter';
formGroup: FormGroup; formGroup: FormGroup;
constructor( constructor(
...@@ -55,9 +56,15 @@ export class LoginComponent implements OnInit { ...@@ -55,9 +56,15 @@ 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(() =>this.auth.redirectUrl ? this.auth.redirectUrl : this.defaultRedirectUrl), 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(() => this.snackBar.open('Connexion réussie !', '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