Esempio n. 1
0
 @RequestMapping(value = "/userpic/upload", method = RequestMethod.POST)
 public String uploadUserPicture(
     @RequestPart("profilePicture") Part userPicrure, Principal principal) throws IOException {
   User user = userService.findUser(principal.getName());
   userService.uploadPicture(userPicrure, user.getId());
   return "redirect:/";
 }
Esempio n. 2
0
 @RequestMapping(value = "/signup", method = RequestMethod.POST)
 public String registerUser(@Valid User user, Errors errors, Model model) {
   if (errors.hasErrors()) return "signup";
   if (userService.findUser(user.getUsername()) != null) {
     Alert alert =
         new Alert(
             AlertType.DANGER,
             "Error!",
             "User with name " + user.getUsername() + " already registered");
     model.addAttribute(alert);
     return "signup";
   }
   userService.newUser(user, Role.ROLE_USER);
   return "redirect:/";
 }
Esempio n. 3
0
 @RequestMapping(value = "/userpic/remove", method = RequestMethod.POST)
 public String removeUserPicture(Principal principal) {
   User user = userService.findUser(principal.getName());
   userService.removePicture(user.getId());
   return "redirect:/";
 }