Merge pull request #59 from AlineRinquin/forgot-reset-password
Forgot reset password
This commit is contained in:
commit
4aa5469a04
@ -36,7 +36,7 @@ const routes: Routes = [
|
|||||||
{ path: 'password-oublie', component: PageForgotPasswordComponent },
|
{ path: 'password-oublie', component: PageForgotPasswordComponent },
|
||||||
{ path: 'menu', canActivate: [AuthGuard], component: PageMenuSemaineComponent },
|
{ path: 'menu', canActivate: [AuthGuard], component: PageMenuSemaineComponent },
|
||||||
{ path: 'repertoire', canActivate: [AuthGuard], component: PageRepertoireComponent },
|
{ path: 'repertoire', canActivate: [AuthGuard], component: PageRepertoireComponent },
|
||||||
{ path: 'reinitialisation-password', component: PageResetPasswordComponent },
|
{ path: 'reinitialisation-password/:uuid', component: PageResetPasswordComponent },
|
||||||
{ path: 'creation-compte', component: PageSignupComponent },
|
{ path: 'creation-compte', component: PageSignupComponent },
|
||||||
{ path: 'page-support', component: PageSupportComponent},
|
{ path: 'page-support', component: PageSupportComponent},
|
||||||
{ path: 'to-do-list', canActivate: [AuthGuard], component: PageToDoListComponent },
|
{ path: 'to-do-list', canActivate: [AuthGuard], component: PageToDoListComponent },
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
routerLinkActive="active-custom">S'inscrire</button>
|
routerLinkActive="active-custom">S'inscrire</button>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
<a routerLink="/password-oublie" routerLinkActive="active-custom" class="nav-link">password perdu ?</a>
|
||||||
<div *ngIf="errorForm">
|
<div *ngIf="errorForm">
|
||||||
<p class="text-danger">Il manque des informations dans le formulaire...</p>
|
<p class="text-danger">Il manque des informations dans le formulaire...</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,10 +9,22 @@
|
|||||||
<label for="floatingInput">Adresse email</label>
|
<label for="floatingInput">Adresse email</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="w-100 btn btn-lg btn-success" type="submit" [disabled]="forgotForm.invalid" routerLink="../reinitialisation-password"
|
<!-- <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>
|
routerLinkActive="active-custom">Ré-initialiser mon mot de passe</button> -->
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="w-100 btn btn-lg btn-outline-success"
|
||||||
|
type="submit"
|
||||||
|
[disabled]="forgotForm.invalid">
|
||||||
|
Ré-initialiser mon mot de passe
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
<br/> <br/>
|
||||||
|
<div *ngIf="isShow">
|
||||||
|
<div class="alert alert-{{alert.type}}" role="alert">
|
||||||
|
{{alert.content}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!--
|
<!--
|
||||||
<div *ngIf="errorForm">
|
<div *ngIf="errorForm">
|
||||||
<p class="text-danger">Il manque des informations dans le formulaire...</p>
|
<p class="text-danger">Il manque des informations dans le formulaire...</p>
|
||||||
|
@ -7,6 +7,9 @@ import {
|
|||||||
FormGroup,
|
FormGroup,
|
||||||
Validators,
|
Validators,
|
||||||
} from '@angular/forms';
|
} from '@angular/forms';
|
||||||
|
import { Membre } from 'src/app/models/membre';
|
||||||
|
import { MailService } from 'src/app/services/mail.service';
|
||||||
|
import { Mail } from 'src/app/models/mail';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-forgot-password',
|
selector: 'app-page-forgot-password',
|
||||||
@ -14,18 +17,76 @@ import {
|
|||||||
styleUrls: ['./page-forgot-password.component.scss']
|
styleUrls: ['./page-forgot-password.component.scss']
|
||||||
})
|
})
|
||||||
export class PageForgotPasswordComponent implements OnInit {
|
export class PageForgotPasswordComponent implements OnInit {
|
||||||
constructor(private authService: AuthService, private router: Router) {
|
|
||||||
|
|
||||||
|
alert : any;
|
||||||
|
isShow : boolean;
|
||||||
|
|
||||||
|
constructor(private authService: AuthService, private router: Router, private mailService: MailService,) {
|
||||||
|
this.alert = "";
|
||||||
|
this.isShow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {}
|
ngOnInit(): void {}
|
||||||
|
|
||||||
public onSubmit(submittedForm: any): void {
|
public onSubmit(submittedForm: any): void {
|
||||||
console.log(submittedForm.form.value);
|
const membre: Membre = {
|
||||||
|
nom: "",
|
||||||
|
prenom: "",
|
||||||
|
dateNaissance: new Date(),
|
||||||
|
email: submittedForm.form.value.email,
|
||||||
|
password: "",
|
||||||
|
roleList: ["ROLE_PARENT"],
|
||||||
|
couleur: "",
|
||||||
|
passwordConfirm: ""
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(membre);
|
||||||
|
// this.authService.forgotPassword(membre).subscribe((resp) => {
|
||||||
|
// console.log('----'+resp)
|
||||||
|
// });
|
||||||
|
|
||||||
|
this.authService.forgotPassword(membre).subscribe(
|
||||||
|
{
|
||||||
|
next: result => {
|
||||||
|
this.alert={"type":"success", "content":"Un mail à été envoyé !"};
|
||||||
|
this.isShow = true;
|
||||||
|
const mail: Mail = {
|
||||||
|
recipient: submittedForm.form.value.email,
|
||||||
|
subject: "Votre mot de passe Organizee",
|
||||||
|
//message: 'Votre mot de passe'
|
||||||
|
message: `
|
||||||
|
Bonjour!\n
|
||||||
|
Vous avez fait une demande de ré-initialisation de mot de passe. \n
|
||||||
|
Cliquez sur le lien pour définir un nouveau mot de passe: \n
|
||||||
|
Lien : http://192.168.1.16:4200/reinitialisation-password/${result}`
|
||||||
|
};
|
||||||
|
this.mailService.envoiMailText(mail)?.subscribe((respMail) =>{
|
||||||
|
console.log("Mail envoyé");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
error: err => {
|
||||||
|
this.alert={"type":"danger", "content":"Le mail a merdé, ou il n'y a personne ds la bdd !"};
|
||||||
|
this.isShow = true;
|
||||||
|
},
|
||||||
|
complete: () => console.log('DONE!')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// service resetpassword
|
||||||
|
// creer un random et le mettre dans password
|
||||||
|
//service envoi de mail // envoyer un lien avec ce random
|
||||||
|
// nouveau formulaire de reset password
|
||||||
|
// update du password
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// const email = submittedForm.form.value['email'];
|
// const email = submittedForm.form.value['email'];
|
||||||
// console.log(email);
|
// console.log(email);
|
||||||
window.alert("Vous allez recevoir un email pour re-initialiser votre mot de passe !")
|
//window.alert("Vous allez recevoir un email pour re-initialiser votre mot de passe !")
|
||||||
// this.router.navigate(['reinitialisation-password']);
|
// this.router.navigate(['reinitialisation-password']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,45 @@
|
|||||||
<app-header></app-header>
|
<app-header></app-header>
|
||||||
<div class="reset-form text-center">
|
<div class="reset-form text-center">
|
||||||
<main class="form-reset">
|
<main class="form-reset">
|
||||||
<form (ngSubmit)="onSubmit(resetForm)" #resetForm="ngForm">
|
<form (ngSubmit)="onSubmit()" [formGroup]="resetForm">
|
||||||
<h3>Entrez ici votre email et votre nouveau mot de passe</h3>
|
<h3>Entrez ici votre email et votre nouveau mot de passe</h3>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="email" class="form-control" id="floatingEmail" placeholder="" name="email" ngModel required
|
<input
|
||||||
[ngClass]="{'is-valid': resetForm.form.touched && resetForm.form.value['email'] != '' ,
|
type="password"
|
||||||
'is-invalid': resetForm.form.touched && resetForm.form.value['email'] == ''}">
|
class="form-control"
|
||||||
<label for="floatingEmail">Email</label>
|
id="floatingPassword"
|
||||||
|
placeholder=""
|
||||||
|
name="password"
|
||||||
|
formControlName="passwordFc"
|
||||||
|
[ngClass]="{
|
||||||
|
'is-valid':
|
||||||
|
resetForm.controls['passwordFc'].touched &&
|
||||||
|
resetForm.controls['passwordFc'].valid,
|
||||||
|
'is-invalid':
|
||||||
|
resetForm.controls['passwordFc'].touched &&
|
||||||
|
!resetForm.controls['passwordFc'].valid
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<label for="floatingPassword">MOT DE PASSE</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="password" class="form-control" id="floatingPassword" placeholder="" name="password" ngModel
|
<input
|
||||||
required [ngClass]="{'is-valid': resetForm.form.touched && resetForm.form.value['password'] != '' ,
|
type="password"
|
||||||
'is-invalid': resetForm.form.touched && resetForm.form.value['password'] == ''}">
|
class="form-control"
|
||||||
<label for="floatingPassword">Mot de passe</label>
|
id="floatingpasswordConfirm"
|
||||||
|
placeholder=""
|
||||||
|
name="passwordConfirm"
|
||||||
|
formControlName="passwordConfirmFc"
|
||||||
|
[ngClass]="{
|
||||||
|
'is-valid':
|
||||||
|
resetForm.controls['passwordConfirmFc'].touched &&
|
||||||
|
resetForm.controls['passwordConfirmFc'].valid,
|
||||||
|
'is-invalid':
|
||||||
|
resetForm.controls['passwordConfirmFc'].touched &&
|
||||||
|
!resetForm.controls['passwordConfirmFc'].valid
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<label for="floatingPasswordConfirm">CONFIRMEZ VOTRE MOT DE PASSE</label>
|
||||||
</div>
|
</div>
|
||||||
<button class="w-100 btn btn-outline-success" type="submit" [disabled]="resetForm.invalid">Enregistrer</button>
|
<button class="w-100 btn btn-outline-success" type="submit" [disabled]="resetForm.invalid">Enregistrer</button>
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { Membre } from 'src/app/models/membre';
|
||||||
import { AuthService } from 'src/app/services/auth.service';
|
import { AuthService } from 'src/app/services/auth.service';
|
||||||
|
|
||||||
|
|
||||||
@ -9,20 +11,80 @@ import { AuthService } from 'src/app/services/auth.service';
|
|||||||
styleUrls: ['./page-reset-password.component.scss']
|
styleUrls: ['./page-reset-password.component.scss']
|
||||||
})
|
})
|
||||||
export class PageResetPasswordComponent implements OnInit {
|
export class PageResetPasswordComponent implements OnInit {
|
||||||
|
public resetForm: FormGroup;
|
||||||
|
uuid:string;
|
||||||
|
constructor(private authService: AuthService, private router: Router,private fb: FormBuilder, private activatedRoute: ActivatedRoute) {
|
||||||
|
this.resetForm = new FormGroup({});
|
||||||
|
this.uuid = this.activatedRoute.snapshot.params['uuid'];
|
||||||
|
}
|
||||||
|
|
||||||
constructor(private authService: AuthService, private router: Router,) { }
|
ngOnInit(): void {
|
||||||
|
this.resetForm = this.fb.group(
|
||||||
|
{
|
||||||
|
passwordFc: new FormControl('', [
|
||||||
|
Validators.minLength(8),
|
||||||
|
Validators.required,
|
||||||
|
]),
|
||||||
|
passwordConfirmFc: new FormControl('', [
|
||||||
|
Validators.minLength(8),
|
||||||
|
Validators.required,
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validator: this.ConfirmedValidator('passwordFc', 'passwordConfirmFc'),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void { }
|
// public onSubmit(submittedForm: any): void {
|
||||||
|
// console.log(submittedForm.form.value);
|
||||||
|
// const password = submittedForm.form.value['password'];
|
||||||
|
// console.log(email);
|
||||||
|
// this.authService.resetPassword(email, password).subscribe((resp: any) => {
|
||||||
|
// window.alert("Votre mot de passe est bien ré-initialisé !")
|
||||||
|
// this.router.navigate(['accueil']);
|
||||||
|
|
||||||
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) => {
|
|
||||||
window.alert("Votre mot de passe est bien ré-initialisé !")
|
|
||||||
this.router.navigate(['accueil']);
|
|
||||||
|
|
||||||
});
|
public onSubmit(): void {
|
||||||
|
console.log('value : ', this.resetForm.value);
|
||||||
|
console.log('form : ', this.resetForm);
|
||||||
|
const passwordValue = this.resetForm.value['passwordFc'];
|
||||||
|
const passwordConfirmValue = this.resetForm.value['passwordConfirmFc'];
|
||||||
|
|
||||||
|
const membre: Membre = {
|
||||||
|
nom: "",
|
||||||
|
prenom: "",
|
||||||
|
dateNaissance: new Date(),
|
||||||
|
email: "",
|
||||||
|
password: passwordValue,
|
||||||
|
roleList: ["ROLE_PARENT"],
|
||||||
|
couleur: "",
|
||||||
|
passwordConfirm: ""
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.authService.resetPassword(membre,this.uuid).subscribe((resp) => {
|
||||||
|
this.router.navigate(['accueil']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfirmedValidator(controlName: string, matchingControlName: string) {
|
||||||
|
return (formGroup: FormGroup) => {
|
||||||
|
const control = formGroup.controls[controlName];
|
||||||
|
const matchingControl = formGroup.controls[matchingControlName];
|
||||||
|
if (
|
||||||
|
matchingControl.errors &&
|
||||||
|
!matchingControl.errors['confirmedValidator']
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (control.value !== matchingControl.value) {
|
||||||
|
matchingControl.setErrors({ confirmedValidator: true });
|
||||||
|
} else {
|
||||||
|
matchingControl.setErrors(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,17 +44,13 @@ export class AuthService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
forgotPassword(email: string): Observable<any> {
|
forgotPassword(membre: Membre): Observable<any> {
|
||||||
const body = {
|
return this.http.post(`${this.apiUrl}/membres/forgot-password`, membre, {responseType: "text"});
|
||||||
email: email,
|
|
||||||
};
|
|
||||||
return this.http.get(`${this.apiUrl}/membres/forgot-password`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPassword(email: string, password: string): Observable<any> {
|
resetPassword(membre: Membre, uuid:string): Observable<any> {
|
||||||
const body = password;
|
console.log('--'+uuid+' / '+membre);
|
||||||
console.log(password);
|
return this.http.put(`${this.apiUrl}/membres/reset-password/${uuid}`, membre);
|
||||||
return this.http.put(`${this.apiUrl}/membres/reset-password/${email}`, body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
creationTeam(team: Team): Observable<any> {
|
creationTeam(team: Team): Observable<any> {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
apiUrl: 'http://localhost:8088',
|
apiUrl: 'http://localhost:8080',
|
||||||
tokenKey: 'TOKEN-ORGANIZEE',
|
tokenKey: 'TOKEN-ORGANIZEE',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user