Skip to content
Snippets Groups Projects
Commit 55c47013 authored by salazard's avatar salazard
Browse files

Merge branch 'new_signup' of gitlab.viarezo.fr:salazard/oser-frontend into new_signup

parents 574a43d7 8e6b4197
No related branches found
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();
} }
......
...@@ -7,10 +7,8 @@ ...@@ -7,10 +7,8 @@
</p> </p>
<div class="text-center"> <div class="text-center">
<button mat-raised-button color="primary" > <button mat-raised-button color="primary" routerLink='/inscription/student-charter' >
<a routerLink='/inscription/student-charter'>
Suivant Suivant
</a>
</button> </button>
</div> </div>
</app-form-page> </app-form-page>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment