reset password fonctionne

This commit is contained in:
Blandine Bajard 2022-01-21 12:55:15 +01:00
parent 63e8f73f4e
commit 8d481cece8
1 changed files with 12 additions and 8 deletions

View File

@ -69,19 +69,20 @@ public class MembreController {
return membreService.findAllUsers().stream().map(appUser -> new MembreDto(appUser.getEmail(), appUser.getRoleList())).collect(Collectors.toList()); return membreService.findAllUsers().stream().map(appUser -> new MembreDto(appUser.getEmail(), appUser.getRoleList())).collect(Collectors.toList());
} }
//cette methode ne fonctionne pas parce que ça affiche "trouvé" dans tous les cas
@GetMapping("/forgot-password") @GetMapping("/forgot-password")
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity<?> findUserByEmail(@RequestBody Membre findUserByEmail) public ResponseEntity<?> findUserByEmail(@RequestBody Membre findUserByEmail) {
{
try {
try {
this.membreService.findUserByEmail(findUserByEmail); this.membreService.findUserByEmail(findUserByEmail);
return ResponseEntity.ok("ok"); return ResponseEntity.status(HttpStatus.OK).body("Email trouvé !");
} catch(Exception e)
{ } catch (EntityNotFoundException e) {
return ResponseEntity.notFound().build();
return ResponseEntity.status(HttpStatus.OK).body("Email introuvable !");
} }
} }
@PutMapping("/reset-password/{email}") @PutMapping("/reset-password/{email}")
@ -95,7 +96,10 @@ public class MembreController {
resultMembre.setPassword(passwordEncoder.encode(password)); resultMembre.setPassword(passwordEncoder.encode(password));
System.out.println(password);
this.membreRepo.save(resultMembre); this.membreRepo.save(resultMembre);
System.out.println(resultMembre.getPassword());
} catch (Exception e) { } catch (Exception e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());