use of com.nixmash.blog.jpa.model.UserConnection in project nixmash-blog by mintster.
the class UserController method signup.
@RequestMapping(value = "/signup", method = POST)
public String signup(@Valid @ModelAttribute("socialUserDTO") SocialUserDTO socialUserDTO, BindingResult result, WebRequest request, RedirectAttributes redirectAttributes) {
if (webUI.isNixMash()) {
return "redirect:/";
}
if (result.hasErrors()) {
return SIGNUP_VIEW;
}
UserDTO userDTO = createUserDTO(socialUserDTO);
User user = userService.create(userDTO);
providerSignInUtils.doPostSignUp(userDTO.getUsername(), request);
UserConnection userConnection = userService.getUserConnectionByUserId(userDTO.getUsername());
if (userConnection.getImageUrl() != null) {
try {
webUI.processProfileImage(userConnection.getImageUrl(), user.getUserKey());
userService.updateHasAvatar(user.getId(), true);
} catch (IOException e) {
logger.error("ImageUrl IOException for username: {0}", user.getUsername());
}
}
SignInUtils.authorizeUser(user);
redirectAttributes.addFlashAttribute("connectionWelcomeMessage", true);
return "redirect:/";
}
Aggregations