Search in sources :

Example 1 with UserConnection

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:/";
}
Also used : User(com.nixmash.blog.jpa.model.User) SocialUserDTO(com.nixmash.blog.jpa.dto.SocialUserDTO) UserDTO(com.nixmash.blog.jpa.dto.UserDTO) IOException(java.io.IOException) UserConnection(com.nixmash.blog.jpa.model.UserConnection)

Aggregations

SocialUserDTO (com.nixmash.blog.jpa.dto.SocialUserDTO)1 UserDTO (com.nixmash.blog.jpa.dto.UserDTO)1 User (com.nixmash.blog.jpa.model.User)1 UserConnection (com.nixmash.blog.jpa.model.UserConnection)1 IOException (java.io.IOException)1