Esempio n. 1
0
 @RequestMapping(value = "/adminEditUser", method = RequestMethod.POST)
 public String updateUser(@ModelAttribute(value = "user") User user, BindingResult result) {
   if (user != null) {
     userService.updateUser(user);
   }
   return "redirect:/adminPanel";
 }
Esempio n. 2
0
  @RequestMapping(value = "adminPanel", method = RequestMethod.GET)
  public String adminPanel(ModelMap model, Principal principal) {

    // User admin = userService.getUser(principal.getName());
    model.addAttribute("users", userService.getAllUsers());

    return "adminPanel";
  }
Esempio n. 3
0
  @RequestMapping(value = "adminEditUser", method = RequestMethod.GET)
  public String editUser(HttpServletRequest request, ModelMap model) {

    String id = request.getParameter("id");
    if (id != null && !id.isEmpty()) {
      model.addAttribute("user", userService.getUser(Integer.parseInt(id)));
      return "adminEditUser";
    }
    return "adminPanel";
  }
Esempio n. 4
0
 @RequestMapping(value = "/adminDeleteUser", method = RequestMethod.GET)
 public String deleteAccount(HttpServletRequest request, Principal principal) {
   String id = request.getParameter("id");
   if (id != null && !id.isEmpty()) {
     userService.removeUser(Long.parseLong(id));
   }
   HttpSession session = request.getSession(false);
   if (session != null) {
     session.invalidate();
   }
   return "redirect:/adminPanel";
 }