[HOTFIX] Fix change password in intern
This commit is contained in:
parent
701e3c9cf6
commit
471d859987
|
@ -94,25 +94,22 @@ public class CustomersIndexController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/{id}/resetPassword")
|
@PostMapping("/{id}/resetPassword")
|
||||||
public String resetPassword(@PathVariable("id") Long id,
|
public String resetPassword(Model model,
|
||||||
|
@PathVariable("id") Long id,
|
||||||
@RequestParam("password") String password,
|
@RequestParam("password") String password,
|
||||||
@RequestParam("password2") String password2,
|
@RequestParam("password2") String password2,
|
||||||
|
HttpServletResponse response,
|
||||||
HttpServletRequest request
|
HttpServletRequest request
|
||||||
) {
|
) {
|
||||||
if (!password.equals(password2)) {
|
if (!password.equals(password2)) {
|
||||||
request.setAttribute("error", "Passwörter stimmen nicht überein!");
|
request.setAttribute("error", "Passwörter stimmen nicht überein!");
|
||||||
return "intern/customers/id";
|
return internCustomersId(model, id, response, request);
|
||||||
}
|
}
|
||||||
User user = userRepository.findById(id).get();
|
User user = userRepository.findById(id).get();
|
||||||
if (!user.validatePassword(password)) {
|
user.setPassword(password);
|
||||||
request.setAttribute("error", "Die Passwörter stimmen nicht mit dem Original überein!");
|
|
||||||
return "intern/customers/id";
|
|
||||||
}
|
|
||||||
user.setPassword("12345");
|
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
request.setAttribute("info", "Passwort wurde auf 12345 geändert!");
|
|
||||||
|
|
||||||
return "intern/customers/id";
|
return "redirect:/intern/customers/" + id.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue