Ejemplo n.º 1
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());
  }