feature/customers #58
@ -61,28 +61,44 @@ public class CustomersIndexController {
|
|||||||
|
|
||||||
|
|||||||
@PostMapping("/{id}/changeState")
|
@PostMapping("/{id}/changeState")
|
||||||
public String changeState(@PathVariable("id") Long id,
|
public String changeState(@PathVariable("id") Long id,
|
||||||
@RequestParam("active") Boolean active,
|
@RequestParam(value = "active", required = false) String active,
|
||||||
@RequestParam("ma") Boolean ma
|
@RequestParam(value = "ma",required = false) String ma
|
||||||
){
|
){
|
||||||
System.out.println(id);
|
User user = userRepository.findById(id).get();
|
||||||
System.out.println(active);
|
|
||||||
System.out.println(ma);
|
|
||||||
|
|
||||||
//TODO: Implement this!!
|
if(active == null)
|
||||||
|
user.isActive = false;
|
||||||
|
else
|
||||||
|
user.isActive = true;
|
||||||
|
|
||||||
return "/intern/customers/id";
|
if(ma == null)
|
||||||
|
user.isEmployee = false;
|
||||||
|
else
|
||||||
|
user.isEmployee = true;
|
||||||
|
|
||||||
|
userRepository.save(user);
|
||||||
|
|
||||||
|
return "redirect:/intern/customers/" + id.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/{id}/resetPassword")
|
@PostMapping("/{id}/resetPassword")
|
||||||
public String resetPassword(@PathVariable("id") Long id,
|
public String resetPassword(@PathVariable("id") Long id,
|
||||||
@RequestParam("password") String password,
|
@RequestParam("password") String password,
|
||||||
@RequestParam("password2") String password2
|
@RequestParam("password2") String password2,
|
||||||
|
HttpServletRequest request
|
||||||
){
|
){
|
||||||
System.out.println(id);
|
if(!password.equals(password2)){
|
||||||
System.out.println(password);
|
request.setAttribute("error", "Passwörter stimmen nicht überein!");
|
||||||
System.out.println(password2);
|
return "/intern/customers/id";
|
||||||
|
}
|
||||||
//TODO: Implement this!!
|
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");
|
||||||
|
userRepository.save(user);
|
||||||
|
request.setAttribute("info", "Passwort wurde auf 12345 geändert!");
|
||||||
|
|
||||||
return "/intern/customers/id";
|
return "/intern/customers/id";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user
Das userRepository fehlt.
siehe
938d16301d