78.4 Reset Password (#9)

This commit is contained in:
Art
2021-09-09 23:17:11 +03:00
parent e400f04a24
commit c399d1cf8d
2 changed files with 42 additions and 0 deletions

View File

@ -80,6 +80,17 @@ public class UserResource {
return userService.findAll();
}
@PostMapping("/resetPassword/{email}")
public HttpResponse resetPassword(@PathVariable String email) {
userService.resetPassword(email);
return HttpResponse.builder()
.httpStatusCode(OK.value())
.httpStatus(OK)
.reason(OK.getReasonPhrase())
.message("Password reset successfully. Check your email for new password")
.build();
}
private void authenticate(String username, String password) {
Authentication auth = new UsernamePasswordAuthenticationToken(username, password);
authenticationManager.authenticate(auth);