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