From 471d8599872ebc1304e751a253599adf78a9b850 Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Thu, 2 Jul 2020 00:50:20 +0200 Subject: [PATCH] [HOTFIX] Fix change password in intern --- .../customers/CustomersIndexController.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/web_backend/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomersIndexController.java b/web_backend/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomersIndexController.java index 336aabc..2db3653 100644 --- a/web_backend/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomersIndexController.java +++ b/web_backend/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomersIndexController.java @@ -94,25 +94,22 @@ public class CustomersIndexController { } @PostMapping("/{id}/resetPassword") - public String resetPassword(@PathVariable("id") Long id, + public String resetPassword(Model model, + @PathVariable("id") Long id, @RequestParam("password") String password, @RequestParam("password2") String password2, + HttpServletResponse response, HttpServletRequest request ) { if (!password.equals(password2)) { request.setAttribute("error", "Passwörter stimmen nicht überein!"); - return "intern/customers/id"; + return internCustomersId(model, id, response, request); } User user = userRepository.findById(id).get(); - if (!user.validatePassword(password)) { - request.setAttribute("error", "Die Passwörter stimmen nicht mit dem Original überein!"); - return "intern/customers/id"; - } - user.setPassword("12345"); + user.setPassword(password); userRepository.save(user); - request.setAttribute("info", "Passwort wurde auf 12345 geändert!"); - return "intern/customers/id"; + return "redirect:/intern/customers/" + id.toString(); } }