@RequestMapping("{id}/form") public String updateForm(@LoginUser SocialUser loginUser, @PathVariable Long id, Model model) throws Exception { SocialUser socialUser = userService.findById(id); if (!loginUser.isSameUser(socialUser)) { throw new IllegalArgumentException("You cann't change another user!"); } model.addAttribute("user", new UserForm(socialUser.getUserId(), socialUser.getEmail())); model.addAttribute("socialUser", socialUser); return "users/form"; }
@RequestMapping("/{id}") public String profileById(@PathVariable Long id) throws Exception { SocialUser socialUser = userService.findById(id); return String.format( "redirect:/users/%d/%s", id, URLEncoder.encode(socialUser.getUserId(), "UTF-8")); }