forgot-pwd + signup
This commit is contained in:
parent
559be4fbd9
commit
673887a81c
File diff suppressed because it is too large
Load Diff
|
@ -25,7 +25,7 @@
|
||||||
"zone.js": "~0.11.4"
|
"zone.js": "~0.11.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "~13.0.3",
|
"@angular-devkit/build-angular": "^13.1.4",
|
||||||
"@angular/cli": "~13.0.3",
|
"@angular/cli": "~13.0.3",
|
||||||
"@angular/compiler-cli": "~13.0.0",
|
"@angular/compiler-cli": "~13.0.0",
|
||||||
"@types/jasmine": "~3.10.0",
|
"@types/jasmine": "~3.10.0",
|
||||||
|
|
|
@ -26,7 +26,7 @@ const routes: Routes = [
|
||||||
{ path: 'password-oublie', component: PageForgotPasswordComponent },
|
{ path: 'password-oublie', component: PageForgotPasswordComponent },
|
||||||
{ path: 'menu', component: PageMenuSemaineComponent },
|
{ path: 'menu', component: PageMenuSemaineComponent },
|
||||||
{ path: 'repertoire', component: PageRepertoireComponent },
|
{ path: 'repertoire', component: PageRepertoireComponent },
|
||||||
{ path: 'reinitialisation-password', component: PageResetPasswordComponent },
|
{ path: 'reset-password', component: PageResetPasswordComponent },
|
||||||
{ path: 'creation-compte', component: PageSignupComponent },
|
{ path: 'creation-compte', component: PageSignupComponent },
|
||||||
{ path: 'to-do-list', component: PageToDoListComponent },
|
{ path: 'to-do-list', component: PageToDoListComponent },
|
||||||
{ path: 'modifier-membre', component: PageUpdateMemberComponent },
|
{ path: 'modifier-membre', component: PageUpdateMemberComponent },
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
export interface Membre {
|
export interface Membre {
|
||||||
firstName: string;
|
prenom : string;
|
||||||
lastName: string;
|
nom: string;
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
dateNaissance: Date;
|
dateNaissance: Date;
|
||||||
teamName: string;
|
|
||||||
profil: boolean;
|
|
||||||
passwordConfirm: string;
|
passwordConfirm: string;
|
||||||
|
roleList: string[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,23 @@
|
||||||
<app-header></app-header>
|
<app-header></app-header>
|
||||||
|
<div class="signin-form text-center">
|
||||||
|
<main class="form-forgot">
|
||||||
|
<form (ngSubmit)="onSubmit(forgotForm)" #forgotForm="ngForm">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="email" class="form-control" id="floatingInput" placeholder="" name="email" ngModel required
|
||||||
|
[ngClass]="{'is-valid': forgotForm.form.touched && forgotForm.form.value['email'] != '' ,
|
||||||
|
'is-invalid': forgotForm.form.touched && forgotForm.form.value['email'] == ''}">
|
||||||
|
<label for="floatingInput">Adresse email</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="w-100 btn btn-lg btn-success" type="submit" [disabled]="forgotForm.invalid" routerLink="../reinitialisation-password"
|
||||||
|
routerLinkActive="active-custom">Ré-initialiser mon mot de passe</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div *ngIf="errorForm">
|
||||||
|
<p class="text-danger">Il manque des informations dans le formulaire...</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
.forgot-form {
|
||||||
|
height: 100vh;
|
||||||
|
padding-top: 40px;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-forgot {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 330px;
|
||||||
|
padding: 15px;
|
||||||
|
margin: auto;
|
||||||
|
.checkbox {
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-floating:focus-within {
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="email"] {
|
||||||
|
margin-bottom: -1px;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,12 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { AuthService } from '../../services/auth.service';
|
||||||
|
import {
|
||||||
|
FormBuilder,
|
||||||
|
FormControl,
|
||||||
|
FormGroup,
|
||||||
|
Validators,
|
||||||
|
} from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-forgot-password',
|
selector: 'app-page-forgot-password',
|
||||||
|
@ -6,10 +14,25 @@ import { Component, OnInit } from '@angular/core';
|
||||||
styleUrls: ['./page-forgot-password.component.scss']
|
styleUrls: ['./page-forgot-password.component.scss']
|
||||||
})
|
})
|
||||||
export class PageForgotPasswordComponent implements OnInit {
|
export class PageForgotPasswordComponent implements OnInit {
|
||||||
|
public errorForm: boolean;
|
||||||
constructor() { }
|
constructor(private authService: AuthService, private router: Router) {
|
||||||
|
this.errorForm = false;
|
||||||
ngOnInit(): void {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {}
|
||||||
|
public onSubmit(submittedForm: any): void {
|
||||||
|
console.log(submittedForm.form.value);
|
||||||
|
const email = submittedForm.form.value['email'];
|
||||||
|
if (email !== '') {
|
||||||
|
this.authService.forgotPassword(email).subscribe((resp) => {
|
||||||
|
console.log('Component : PageForgotPassword ', resp);
|
||||||
|
this.router.navigate(['reinitialisation-password']);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// afficher une erreur à l'utilisateur
|
||||||
|
this.errorForm = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,107 +2,77 @@
|
||||||
<div class="signup-form text-center">
|
<div class="signup-form text-center">
|
||||||
<main class="form-signup">
|
<main class="form-signup">
|
||||||
<form (ngSubmit)="onSubmit()" [formGroup]="signupForm">
|
<form (ngSubmit)="onSubmit()" [formGroup]="signupForm">
|
||||||
<h1>Merci de vous inscrire</h1>
|
<h1>Incrivez-vous !</h1>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="floatingInputlastName"
|
id="floatingInputlastName"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
name="lastName"
|
name="lastName"
|
||||||
formControlName="lastNameFc"
|
formControlName="lastNameFc"
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['lastNameFc'].touched && signupForm.controls['lastNameFc'].valid,
|
[ngClass]="{'is-valid' : signupForm.controls['lastNameFc'].touched && signupForm.controls['lastNameFc'].valid,
|
||||||
'is-invalid': signupForm.controls['lastNameFc'].touched && !signupForm.controls['lastNameFc'].valid}">
|
'is-invalid': signupForm.controls['lastNameFc'].touched && !signupForm.controls['lastNameFc'].valid}">
|
||||||
<label for="floatingInputlastName">Nom</label>
|
<label for="floatingInputlastName">Nom</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="floatingInputfirstName"
|
id="floatingInputfirstName"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
name="firstName"
|
name="firstName"
|
||||||
formControlName="firstNameFc"
|
formControlName="firstNameFc"
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['firstNameFc'].touched && signupForm.controls['firstNameFc'].valid,
|
[ngClass]="{'is-valid' : signupForm.controls['firstNameFc'].touched && signupForm.controls['firstNameFc'].valid,
|
||||||
'is-invalid': signupForm.controls['firstNameFc'].touched && !signupForm.controls['firstNameFc'].valid}">
|
'is-invalid': signupForm.controls['firstNameFc'].touched && !signupForm.controls['firstNameFc'].valid}">
|
||||||
<label for="floatingInputfirstName">Prénom</label>
|
<label for="floatingInputfirstName">Prénom</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="date"
|
<input type="date"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="floatingInputdateNaissance"
|
id="floatingInputdateNaissance"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
name="dateNaissance"
|
name="dateNaissance"
|
||||||
formControlName="dateNaissanceFc"
|
formControlName="dateNaissanceFc"
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['dateNaissanceFc'].touched && signupForm.controls['dateNaissanceFc'].valid,
|
[ngClass]="{'is-valid' : signupForm.controls['dateNaissanceFc'].touched && signupForm.controls['dateNaissanceFc'].valid,
|
||||||
'is-invalid': signupForm.controls['dateNaissanceFc'].touched && !signupForm.controls['dateNaissanceFc'].valid}">
|
'is-invalid': signupForm.controls['dateNaissanceFc'].touched && !signupForm.controls['dateNaissanceFc'].valid}">
|
||||||
<label for="floatingInputfirstName">Date de naissance</label>
|
<label for="floatingInputfirstName">Date de naissance</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="text"
|
<input type="email"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="floatingInputteamName"
|
id="floatingInput"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
name="teamName"
|
name="email"
|
||||||
formControlName="teamNameFc"
|
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['teamNameFc'].touched && signupForm.controls['teamNameFc'].valid,
|
|
||||||
'is-invalid': signupForm.controls['teamNameFc'].touched && !signupForm.controls['teamNameFc'].valid}">
|
|
||||||
<label for="floatingInputfirstName">Ma team</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<select type="text"
|
|
||||||
class="form-control"
|
|
||||||
id="floatingInputprofil"
|
|
||||||
name="profil"
|
|
||||||
formControlName="profilFc"
|
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['profilFc'].touched && signupForm.controls['profilFc'].valid,
|
|
||||||
'is-invalid': signupForm.controls['profilFc'].touched && !signupForm.controls['profilFc'].valid}">
|
|
||||||
<option>Adulte</option>
|
|
||||||
<option>Enfant</option>
|
|
||||||
</select>
|
|
||||||
<label for="floatingInputfirstName">Profil</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="email"
|
|
||||||
class="form-control"
|
|
||||||
id="floatingInput"
|
|
||||||
placeholder=""
|
|
||||||
name="email"
|
|
||||||
formControlName="emailFc"
|
formControlName="emailFc"
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['emailFc'].touched && signupForm.controls['emailFc'].valid,
|
[ngClass]="{'is-valid' : signupForm.controls['emailFc'].touched && signupForm.controls['emailFc'].valid,
|
||||||
'is-invalid': signupForm.controls['emailFc'].touched && !signupForm.controls['emailFc'].valid}">
|
'is-invalid': signupForm.controls['emailFc'].touched && !signupForm.controls['emailFc'].valid}">
|
||||||
<label for="floatingInput">Adresse email</label>
|
<label for="floatingInput">Adresse email</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="password"
|
<input type="password"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="floatingPassword"
|
id="floatingPassword"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
name="password"
|
name="password"
|
||||||
formControlName="passwordFc"
|
formControlName="passwordFc"
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['passwordFc'].touched && signupForm.controls['passwordFc'].valid,
|
[ngClass]="{'is-valid' : signupForm.controls['passwordFc'].touched && signupForm.controls['passwordFc'].valid,
|
||||||
'is-invalid': signupForm.controls['passwordFc'].touched && !signupForm.controls['passwordFc'].valid}">
|
'is-invalid': signupForm.controls['passwordFc'].touched && !signupForm.controls['passwordFc'].valid}">
|
||||||
<label for="floatingPassword">Mot de passe</label>
|
<label for="floatingPassword">Mot de passe</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="passwordConfirm"
|
<input type="passwordConfirm"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="floatingpasswordConfirm"
|
id="floatingpasswordConfirm"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
name="passwordConfirm"
|
name="passwordConfirm"
|
||||||
formControlName="passwordConfirmFc"
|
formControlName="passwordConfirmFc"
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['passwordConfirmFc'].touched && signupForm.controls['passwordConfirmFc'].valid,
|
[ngClass]="{'is-valid' : signupForm.controls['passwordConfirmFc'].touched && signupForm.controls['passwordConfirmFc'].valid,
|
||||||
'is-invalid': signupForm.controls['passwordConfirmFc'].touched && !signupForm.controls['passwordConfirmFc'].valid}">
|
'is-invalid': signupForm.controls['passwordConfirmFc'].touched && !signupForm.controls['passwordConfirmFc'].valid}">
|
||||||
<label for="floatingPassword">Confirmer mot de passe</label>
|
<label for="floatingPassword">Confirmer mot de passe</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="w-100 btn btn-lg btn-success"
|
<button class="w-100 btn btn-lg btn-success"
|
||||||
type="submit"
|
type="submit"
|
||||||
[disabled]="signupForm.invalid">Je m'inscris !</button>
|
[disabled]="signupForm.invalid">Je m'inscris !</button>
|
||||||
<p>
|
|
||||||
Value : {{ signupForm.value | json }}
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Form valid : {{ signupForm.valid }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
FormGroup,
|
FormGroup,
|
||||||
Validators,
|
Validators,
|
||||||
} from '@angular/forms';
|
} from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router, RouterLink } from '@angular/router';
|
||||||
import { Membre } from '../../models/membre';
|
import { Membre } from '../../models/membre';
|
||||||
import { AuthService } from '../../services/auth.service';
|
import { AuthService } from '../../services/auth.service';
|
||||||
|
|
||||||
|
@ -31,8 +31,7 @@ export class PageSignupComponent implements OnInit {
|
||||||
firstNameFc: new FormControl('', [Validators.required]),
|
firstNameFc: new FormControl('', [Validators.required]),
|
||||||
lastNameFc: new FormControl('', [Validators.required]),
|
lastNameFc: new FormControl('', [Validators.required]),
|
||||||
dateNaissanceFc: new FormControl('', [Validators.required]),
|
dateNaissanceFc: new FormControl('', [Validators.required]),
|
||||||
teamNameFc: new FormControl('', [Validators.required]),
|
roleFc: new FormControl(''),
|
||||||
profilFc: new FormControl('', [Validators.required]),
|
|
||||||
emailFc: new FormControl('', [
|
emailFc: new FormControl('', [
|
||||||
Validators.email,
|
Validators.email,
|
||||||
Validators.required,
|
Validators.required,
|
||||||
|
@ -56,29 +55,27 @@ export class PageSignupComponent implements OnInit {
|
||||||
public onSubmit(): void {
|
public onSubmit(): void {
|
||||||
console.log('value : ', this.signupForm.value);
|
console.log('value : ', this.signupForm.value);
|
||||||
console.log('form : ', this.signupForm);
|
console.log('form : ', this.signupForm);
|
||||||
const firstNameValue = this.signupForm.value['firstNameFc'];
|
const prenomValue = this.signupForm.value['firstNameFc'];
|
||||||
const lastNameValue = this.signupForm.value['lastNameFc'];
|
const nomValue = this.signupForm.value['lastNameFc'];
|
||||||
const emailValue = this.signupForm.value['emailFc'];
|
const emailValue = this.signupForm.value['emailFc'];
|
||||||
const passwordValue = this.signupForm.value['passwordFc'];
|
const passwordValue = this.signupForm.value['passwordFc'];
|
||||||
const dateNaissanceValue = this.signupForm.value['dateNaissanceFc'];
|
const dateNaissanceValue = this.signupForm.value['dateNaissanceFc'];
|
||||||
const teamNameValue = this.signupForm.value['teamNameFc'];
|
|
||||||
const profilValue = this.signupForm.value['profilFc'];
|
|
||||||
const passwordConfirmValue = this.signupForm.value['passwordConfirmFc'];
|
const passwordConfirmValue = this.signupForm.value['passwordConfirmFc'];
|
||||||
|
const roleValue = ['ROLE_PARENT'];
|
||||||
|
|
||||||
const membre: Membre = {
|
const membre: Membre = {
|
||||||
firstName: firstNameValue,
|
prenom: prenomValue,
|
||||||
lastName: lastNameValue,
|
nom: nomValue,
|
||||||
email: emailValue,
|
email: emailValue,
|
||||||
password: passwordValue,
|
password: passwordValue,
|
||||||
dateNaissance: dateNaissanceValue,
|
dateNaissance: dateNaissanceValue,
|
||||||
teamName: teamNameValue,
|
|
||||||
profil: profilValue,
|
|
||||||
passwordConfirm: passwordConfirmValue,
|
passwordConfirm: passwordConfirmValue,
|
||||||
|
roleList: roleValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (membre.email !== '' && membre.password !== '') {
|
if (membre.email !== '' && membre.password !== '') {
|
||||||
this.authService.signup(membre).subscribe((resp) => {
|
this.authService.signup(membre).subscribe((resp) => {
|
||||||
this.router.navigate(['account/signin']);
|
this.router.navigate(['accueil']);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// affichage erreur
|
// affichage erreur
|
||||||
|
|
|
@ -20,7 +20,7 @@ export class AuthService {
|
||||||
signup(membre: Membre): Observable<any> {
|
signup(membre: Membre): Observable<any> {
|
||||||
console.log(membre);
|
console.log(membre);
|
||||||
|
|
||||||
return this.http.post(`${this.apiUrl}/creation-compte`, membre);
|
return this.http.post(`${this.apiUrl}/membres/sign-up`, membre);
|
||||||
}
|
}
|
||||||
|
|
||||||
signin(email: string, password: string): Observable<any> {
|
signin(email: string, password: string): Observable<any> {
|
||||||
|
@ -35,7 +35,7 @@ export class AuthService {
|
||||||
// - pour pouvoir stocker dans le localstorage notre accesstoken
|
// - pour pouvoir stocker dans le localstorage notre accesstoken
|
||||||
// - Sous la clé "TOKEN-LBP"
|
// - Sous la clé "TOKEN-LBP"
|
||||||
|
|
||||||
return this.http.post(`${this.apiUrl}/login`, body).pipe(
|
return this.http.post(`${this.apiUrl}/membres/sign-in`, body).pipe(
|
||||||
map((x: any) => {
|
map((x: any) => {
|
||||||
console.log('Service : ', x.accessToken);
|
console.log('Service : ', x.accessToken);
|
||||||
// Modification à faire ici
|
// Modification à faire ici
|
||||||
|
@ -45,14 +45,10 @@ export class AuthService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
forgotPassword(email: string, password: string): Observable<any> {
|
forgotPassword(email: string): Observable<any> {
|
||||||
const body = {
|
const body = {
|
||||||
email: email,
|
email: email,
|
||||||
password: password,
|
|
||||||
};
|
};
|
||||||
|
return this.http.post(`${this.apiUrl}/membres/forgot-password`, body);
|
||||||
console.log('Mon body : ', body);
|
|
||||||
|
|
||||||
return this.http.post(`${this.apiUrl}/forgot-psw`, body);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
apiUrl: 'http://localhost:3306',
|
apiUrl: 'http://localhost:8088',
|
||||||
tokenKey: 'TOKEN-ORGANIZEE',
|
tokenKey: 'TOKEN-ORGANIZEE',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue