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

post

parent 190a0287
No related branches found
No related tags found
1 merge request!80New signup
...@@ -22,7 +22,7 @@ export class AuthService { ...@@ -22,7 +22,7 @@ export class AuthService {
private loginUrl = environment.apiUrl + 'auth/get-token/'; private loginUrl = environment.apiUrl + '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 + 'charter'; private mandatorySignatureUrl = environment.apiUrl + 'charter/';
//add the corresponding path in backend interface //add the corresponding path in backend interface
...@@ -100,6 +100,13 @@ export class AuthService { ...@@ -100,6 +100,13 @@ export class AuthService {
return false; return false;
} }
sendSignatureCharter(email: any) : Observable<Boolean> {
return this.http.post<Boolean>( this.mandatorySignatureUrl+'?email=' +email,{}).pipe(
map((data: any) => {
return data}),
);
}
logout() { logout() {
this.user.destroy(); this.user.destroy();
this.token.destroy(); this.token.destroy();
......
...@@ -4,7 +4,7 @@ import { FormGroup, FormBuilder } from '@angular/forms'; ...@@ -4,7 +4,7 @@ import { FormGroup, FormBuilder } from '@angular/forms';
import { MatSnackBar } from '@angular/material'; import { MatSnackBar } from '@angular/material';
import { AuthService, MessageService } from 'app/core'; import { AuthService, MessageService } from 'app/core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { filter, map, tap, catchError } from 'rxjs/operators'; import { filter, map, tap, catchError, subscribeOn } from 'rxjs/operators';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
...@@ -18,6 +18,7 @@ export class LoginComponent implements OnInit { ...@@ -18,6 +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;
constructor( constructor(
private router: Router, private router: Router,
...@@ -44,21 +45,34 @@ export class LoginComponent implements OnInit { ...@@ -44,21 +45,34 @@ export class LoginComponent implements OnInit {
}); });
} }
login() { async login() {
var toto = false;
this.loading = true; this.loading = true;
const { email, password } = this.formGroup.value; const { email, password } = this.formGroup.value;
this.messageService.clear(); this.messageService.clear();
this.auth.login(email, password).pipe( await this.auth.login(email, password).pipe(
map(() => this.loginSuccess = true),
catchError(() => { catchError(() => {
this.messageService.error("L'identifiant ou le mot de passe est incorrect."); this.messageService.error("L'identifiant ou le mot de passe est incorrect.");
this.loginSuccess = false;
return of(false); return of(false);
}), }),
tap(() => this.loading = false), tap(() => this.loading = false),
// 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.
).subscribe(); ).subscribe({
complete() {
console.log("login unsuccess");
},
});
if(this.loginSuccess == true){
this.auth.checkSignatureCharter(email).pipe( this.auth.checkSignatureCharter(email).pipe(
catchError(() => { catchError(() => {
...@@ -82,6 +96,7 @@ export class LoginComponent implements OnInit { ...@@ -82,6 +96,7 @@ export class LoginComponent implements OnInit {
this.router.navigate([this.defaultRedirectUrl]); this.router.navigate([this.defaultRedirectUrl]);
} }
}); });
}
} }
} }
\ No newline at end of file
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
</p> </p>
<div class="text-center"> <div class="text-center">
<button mat-raised-button color="primary" [disabled]="!toggleSuivant()" routerLink='/membres/compte/modifier_donnees'> <button mat-raised-button color="primary" (click)="signChart()" [disabled]="!toggleSuivant()" routerLink='/membres/compte/modifier_donnees'>
Terminer l'inscription Terminer l'inscription
</button> </button>
</div> </div>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { AuthService } from 'app/core';
import { Registration, RegistrationService, PasswordErrorStateMatcher,PersonnalData,PersonnalDataService } from '../core'; import { Registration, RegistrationService, PasswordErrorStateMatcher,PersonnalData,PersonnalDataService } from '../core';
import { StudentSignupComponent } from '../student-signup/student-signup.component'; import { StudentSignupComponent } from '../student-signup/student-signup.component';
...@@ -16,7 +17,9 @@ export class ParentsCharterComponent implements OnInit { ...@@ -16,7 +17,9 @@ export class ParentsCharterComponent implements OnInit {
state_button:boolean; state_button:boolean;
constructor() { } constructor(
private auth: AuthService,
) { }
ngOnInit() { ngOnInit() {
...@@ -42,5 +45,10 @@ export class ParentsCharterComponent implements OnInit { ...@@ -42,5 +45,10 @@ export class ParentsCharterComponent implements OnInit {
} }
// send post to url
signChart()
{
console.log("signChart");
this.auth.sendSignatureCharter(this.auth.getUserSnapshot().email).subscribe();
}
} }
// For use when you have a local backend server running // For use when you have a local backend server running
export const environment = { export const environment = {
production: false, production: false,
showcaseApiUrl: 'https://oser-site-vitrine.herokuapp.com/api/', showcaseApiUrl: 'https://oser-cs.fr/api/',
apiUrl: 'http://localhost:8000/api/', apiUrl: 'http://localhost:8000/api/',
numArticles: 3, numArticles: 3,
donateUrl: "https://www.donnerenligne.fr/ouverture-sociale-pour-l-egalite-et-la-reussite/faire-un-don", donateUrl: "https://www.donnerenligne.fr/ouverture-sociale-pour-l-egalite-et-la-reussite/faire-un-don",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
export const environment = { export const environment = {
production: false, production: false,
showcaseApiUrl: 'https://oser-site-vitrine.herokuapp.com/api/', showcaseApiUrl: 'https://oser-site-vitrine.herokuapp.com/api/',
apiUrl: 'https://oser-backend-dev.herokuapp.com/api/', apiUrl: 'http://localhost:8000/api/',
numArticles: 3, numArticles: 3,
donateUrl: "https://www.donnerenligne.fr/ouverture-sociale-pour-l-egalite-et-la-reussite/faire-un-don", donateUrl: "https://www.donnerenligne.fr/ouverture-sociale-pour-l-egalite-et-la-reussite/faire-un-don",
currentCampaignUrl: "", currentCampaignUrl: "",
......
// Development environment (the default)
export const environment = {
production: false,
showcaseApiUrl: 'https://oser-site-vitrine.herokuapp.com/api/',
apiUrl: 'http://oser-backend:8000/api/',
numArticles: 3,
donateUrl: "https://www.donnerenligne.fr/ouverture-sociale-pour-l-egalite-et-la-reussite/faire-un-don",
currentCampaignUrl: "",
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment