コード例 #1
0
ファイル: QnaService.java プロジェクト: shinC/slipp
 public void likeAnswer(SocialUser loginUser, Long answerId) {
   if (!scoreLikeService.alreadyLikedAnswer(answerId, loginUser.getId())) {
     scoreLikeService.saveLikeAnswer(answerId, loginUser.getId());
     Answer answer = answerRepository.findOne(answerId);
     answer.upRank();
     answerRepository.save(answer);
   }
 }
コード例 #2
0
ファイル: UsersController.java プロジェクト: rockyruah/slipp
  @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";
  }
コード例 #3
0
ファイル: SocialUserBuilder.java プロジェクト: daeryong/slipp
 public SocialUser build() {
   SocialUser socialUser = new SocialUser();
   socialUser.setUserId(userId);
   socialUser.setProviderId(providerId);
   socialUser.setProviderUserId(providerUserId);
   socialUser.setRank(rank);
   socialUser.setDisplayName(displayName);
   socialUser.setProfileUrl(profileUrl);
   socialUser.setImageUrl(imageUrl);
   return socialUser;
 }
コード例 #4
0
ファイル: UsersController.java プロジェクト: rockyruah/slipp
  @RequestMapping("{id}/changepassword")
  public String changePasswordForm(
      @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("socialUser", socialUser);
    model.addAttribute("password", new PasswordDto(id));
    return "users/changepassword";
  }
コード例 #5
0
ファイル: UsersController.java プロジェクト: rockyruah/slipp
  @RequestMapping(value = "{id}", method = RequestMethod.PUT)
  public String update(@LoginUser SocialUser loginUser, @PathVariable Long id, UserForm userForm)
      throws Exception {
    SocialUser socialUser = userService.findById(id);
    if (!loginUser.isSameUser(socialUser)) {
      throw new IllegalArgumentException("You cann't change another user!");
    }

    userService.updateSlippUser(loginUser, userForm.getEmail(), userForm.getUserId());

    return "redirect:/users/logout";
  }
コード例 #6
0
ファイル: UsersController.java プロジェクト: rockyruah/slipp
  @RequestMapping(value = "{id}/changepassword", method = RequestMethod.POST)
  public String changePassword(
      @LoginUser SocialUser loginUser, @PathVariable Long id, PasswordDto password, Model model)
      throws Exception {
    SocialUser socialUser = userService.findById(id);

    if (!loginUser.isSameUser(socialUser)) {
      throw new IllegalArgumentException("You cann't change another user!");
    }

    try {
      userService.changePassword(loginUser, password);
      return "redirect:/users/logout";
    } catch (BadCredentialsException e) {
      model.addAttribute("errorMessage", e.getMessage());
      model.addAttribute("socialUser", socialUser);
      model.addAttribute("password", new PasswordDto(id));
      return "users/changepassword";
    }
  }
コード例 #7
0
ファイル: UsersController.java プロジェクト: rockyruah/slipp
 @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"));
 }
コード例 #8
0
ファイル: UsersController.java プロジェクト: rockyruah/slipp
 @RequestMapping(value = "", method = RequestMethod.POST)
 public String create(UserForm user, HttpServletRequest request, HttpServletResponse response) {
   SocialUser socialUser = userService.createSlippUser(user.getUserId(), user.getEmail());
   autoLoginAuthenticator.login(socialUser.getEmail(), socialUser.getRawPassword());
   return "redirect:/";
 }