reset password en cours

This commit is contained in:
Blandine Bajard 2022-01-21 12:30:05 +01:00
parent 673887a81c
commit b994e6be58
5 changed files with 173 additions and 79 deletions

View File

@ -26,7 +26,7 @@ const routes: Routes = [
{ path: 'password-oublie', component: PageForgotPasswordComponent },
{ path: 'menu', component: PageMenuSemaineComponent },
{ path: 'repertoire', component: PageRepertoireComponent },
{ path: 'reset-password', component: PageResetPasswordComponent },
{ path: 'reinitialisation-password', component: PageResetPasswordComponent },
{ path: 'creation-compte', component: PageSignupComponent },
{ path: 'to-do-list', component: PageToDoListComponent },
{ path: 'modifier-membre', component: PageUpdateMemberComponent },

View File

@ -1 +1,26 @@
<app-header></app-header>
<div class="signin-form text-center">
<main class="form-signin">
<form (ngSubmit)="onSubmit(resetForm)" #resetForm="ngForm">
<div class="form-floating">
<input type="email" class="form-control" id="floatingEmail" placeholder="" name="email" ngModel required
[ngClass]="{'is-valid': resetForm.form.touched && resetForm.form.value['email'] != '' ,
'is-invalid': resetForm.form.touched && resetForm.form.value['email'] == ''}">
<label for="floatingEmail">Email</label>
</div>
<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="" name="password" ngModel
required [ngClass]="{'is-valid': resetForm.form.touched && resetForm.form.value['password'] != '' ,
'is-invalid': resetForm.form.touched && resetForm.form.value['password'] == ''}">
<label for="floatingPassword">Mot de passe</label>
</div>
<button class="w-100 btn btn-lg btn-success" type="submit" [disabled]="resetForm.invalid">Se connecter</button>
</form>
</main>
</div>

View File

@ -6,10 +6,21 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./page-reset-password.component.scss']
})
export class PageResetPasswordComponent implements OnInit {
authService: any;
router: any;
constructor() { }
ngOnInit(): void {
}
ngOnInit(): void {}
public onSubmit(submittedForm: any): void {
console.log(submittedForm.form.value);
const password = submittedForm.form.value['password'];
const email = submittedForm.form.value['email'];
console.log(email);
this.authService.resetPassword(email, password).subscribe((resp: any) => {
this.router.navigate(['tableau-de-bord']);
});
}
}

View File

@ -2,78 +2,129 @@
<div class="signup-form text-center">
<main class="form-signup">
<form (ngSubmit)="onSubmit()" [formGroup]="signupForm">
<h1>Incrivez-vous !</h1>
<h1>Inscrivez-vous !</h1>
<div class="form-floating">
<input type="text"
<input
type="text"
class="form-control"
id="floatingInputlastName"
placeholder=""
name="lastName"
formControlName="lastNameFc"
[ngClass]="{'is-valid' : signupForm.controls['lastNameFc'].touched && signupForm.controls['lastNameFc'].valid,
'is-invalid': 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
}"
/>
<label for="floatingInputlastName">Nom</label>
</div>
<div class="form-floating">
<input type="text"
<input
type="text"
class="form-control"
id="floatingInputfirstName"
placeholder=""
name="firstName"
formControlName="firstNameFc"
[ngClass]="{'is-valid' : signupForm.controls['firstNameFc'].touched && signupForm.controls['firstNameFc'].valid,
'is-invalid': 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
}"
/>
<label for="floatingInputfirstName">Prénom</label>
</div>
<div class="form-floating">
<input type="date"
<input
type="date"
class="form-control"
id="floatingInputdateNaissance"
placeholder=""
name="dateNaissance"
formControlName="dateNaissanceFc"
[ngClass]="{'is-valid' : signupForm.controls['dateNaissanceFc'].touched && signupForm.controls['dateNaissanceFc'].valid,
'is-invalid': 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
}"
/>
<label for="floatingInputfirstName">Date de naissance</label>
</div>
<div class="form-floating">
<input type="email"
<input
type="email"
class="form-control"
id="floatingInput"
placeholder=""
name="email"
formControlName="emailFc"
[ngClass]="{'is-valid' : signupForm.controls['emailFc'].touched && signupForm.controls['emailFc'].valid,
'is-invalid': 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
}"
/>
<label for="floatingInput">Adresse email</label>
</div>
<div class="form-floating">
<input type="password"
<input
type="password"
class="form-control"
id="floatingPassword"
placeholder=""
name="password"
formControlName="passwordFc"
[ngClass]="{'is-valid' : signupForm.controls['passwordFc'].touched && signupForm.controls['passwordFc'].valid,
'is-invalid': 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
}"
/>
<label for="floatingPassword">Mot de passe</label>
</div>
<div class="form-floating">
<input type="passwordConfirm"
<input
type="passwordConfirm"
class="form-control"
id="floatingpasswordConfirm"
placeholder=""
name="passwordConfirm"
formControlName="passwordConfirmFc"
[ngClass]="{'is-valid' : signupForm.controls['passwordConfirmFc'].touched && signupForm.controls['passwordConfirmFc'].valid,
'is-invalid': 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
}"
/>
<label for="floatingPassword">Confirmer mot de passe</label>
</div>
<button class="w-100 btn btn-lg btn-success"
<button
class="w-100 btn btn-lg btn-success"
type="submit"
[disabled]="signupForm.invalid">Je m'inscris !</button>
[disabled]="signupForm.invalid"
>
Je m'inscris !
</button>
</form>
</main>
</div>

View File

@ -1,4 +1,5 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { identifierModuleUrl } from '@angular/compiler';
import { Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
@ -51,4 +52,10 @@ export class AuthService {
};
return this.http.post(`${this.apiUrl}/membres/forgot-password`, body);
}
resetPassword(email: string, password: string): Observable<any> {
const body = password;
console.log(password);
return this.http.post(`${this.apiUrl}/membres/reset-password/${email}`, body);
}
}