Example #1
0
  /**
   * 사용자 비밀번호 변경 비밀번호 변경에 성공하면 로그인 화면으로 이동 비밀번호 변경에 실패하면 수정화면으로 돌아간다
   *
   * @return
   */
  @Transactional
  public static Result resetUserPassword() {
    Form<User> userForm = form(User.class).bindFromRequest();

    if (userForm.hasErrors()) {
      return badRequest(ErrorViews.BadRequest.render("error.badrequest"));
    }

    User currentUser = currentUser();
    User user = userForm.get();

    if (!isValidPassword(currentUser, user.oldPassword)) {
      Form<User> currentUserForm = new Form<>(User.class);
      currentUserForm = currentUserForm.fill(currentUser);

      flash(Constants.WARNING, "user.wrongPassword.alert");
      return badRequest(edit.render(currentUserForm, currentUser));
    }

    resetPassword(currentUser, user.password);

    // go to login page
    processLogout();
    flash(Constants.WARNING, "user.loginWithNewPassword");
    return redirect(routes.UserApp.loginForm());
  }
Example #2
0
  /**
   * Responds to a request to delete the specified issue label.
   *
   * <p>This method is used when a user click a button to delete a issue label in issue list,
   * editing issue or new issue page.
   *
   * <p>Deletes an issue label corresponding to the given {@code id}.
   *
   * <p>- Returns {@code 200 OK} if the issue label is deleted succesfully. - Returns {@code 403
   * Forbidden} if the user has no permission to delete the issue label. - Returns {@code 404 Not
   * Found} if no issue label is found.
   *
   * <p>The request must have a {@code _method} parameter and the parameter value must be
   * case-insensitive "delete"; otherwise, returns 400 Bad Request. We use this trick because an
   * HTML Form does not support the DELETE method.
   *
   * @param ownerName Don't use.
   * @param projectName Don't use.
   * @param id the id of the label to be deleted
   * @return the response to the request to delete an issue label
   */
  @Transactional
  @IsAllowed(value = Operation.DELETE, resourceType = ResourceType.ISSUE_LABEL)
  public static Result delete(String ownerName, String projectName, Long id) {
    // _method must be 'delete'
    DynamicForm bindedForm = form().bindFromRequest();
    if (!bindedForm.get("_method").toLowerCase().equals("delete")) {
      return badRequest(ErrorViews.BadRequest.render("_method must be 'delete'."));
    }

    IssueLabel label = IssueLabel.finder.byId(id);
    label.delete();
    return ok();
  }
Example #3
0
 @Override
 public Result onBadRequest(RequestHeader request, String error) {
   AccessLogger.log(request, null, Http.Status.BAD_REQUEST);
   return badRequest(ErrorViews.BadRequest.render());
 }