Пример #1
0
  /**
   * 대표 메일로 설정하기
   *
   * @param id
   * @return
   */
  @Transactional
  public static Result setAsMainEmail(Long id) {
    User currentUser = currentUser();
    Email email = Email.find.byId(id);

    if (currentUser == null || currentUser.isAnonymous() || email == null) {
      return forbidden(ErrorViews.NotFound.render());
    }

    if (!AccessControl.isAllowed(currentUser, email.user.asResource(), Operation.UPDATE)) {
      return forbidden(ErrorViews.Forbidden.render(Messages.get("error.forbidden")));
    }

    String oldMainEmail = currentUser.email;
    currentUser.email = email.email;
    currentUser.removeEmail(email);
    currentUser.update();

    Email newSubEmail = new Email();
    newSubEmail.valid = true;
    newSubEmail.email = oldMainEmail;
    newSubEmail.user = currentUser;
    currentUser.addEmail(newSubEmail);

    return redirect(routes.UserApp.editUserInfoForm());
  }
Пример #2
0
  /**
   * 이메일 삭제
   *
   * @param id
   * @return
   */
  @Transactional
  public static Result deleteEmail(Long id) {
    User currentUser = currentUser();
    Email email = Email.find.byId(id);

    if (currentUser == null || currentUser.isAnonymous() || email == null) {
      return forbidden(ErrorViews.NotFound.render());
    }

    if (!AccessControl.isAllowed(currentUser, email.user.asResource(), Operation.DELETE)) {
      return forbidden(ErrorViews.Forbidden.render(Messages.get("error.forbidden")));
    }

    email.delete();
    return redirect(routes.UserApp.editUserInfoForm());
  }
Пример #3
0
  /**
   * 보조 이메일 확인 메일 보내기
   *
   * @param id
   * @return
   */
  @Transactional
  public static Result sendValidationEmail(Long id) {
    User currentUser = currentUser();
    Email email = Email.find.byId(id);

    if (currentUser == null || currentUser.isAnonymous() || email == null) {
      return forbidden(ErrorViews.NotFound.render());
    }

    if (!AccessControl.isAllowed(currentUser, email.user.asResource(), Operation.UPDATE)) {
      return forbidden(ErrorViews.Forbidden.render(Messages.get("error.forbidden")));
    }

    email.sendValidationEmail();

    flash(Constants.WARNING, "확인 메일을 전송했습니다.");
    return redirect(routes.UserApp.editUserInfoForm());
  }