Beispiel #1
0
 /**
  * 修改密码
  *
  * @return
  */
 public String editPassword() {
   User dbResult = userManager.getById(getCurrUser().getUserID());
   User user = this.userManager.getById(getCurrUser().getUserID());
   String pwd = getRequest().getParameter("password");
   String pwdold = getRequest().getParameter("password_old");
   String msg = "修改密码成功";
   int type = 1;
   if (pwdold.equals(dbResult.getPassword())) {
     dbResult.setPassword(pwd);
     try {
       userManager.saveOrUpdate(dbResult);
       // 提示信息
       Flash.current().success(RESET_PASSWORD_SUCCESS);
     } catch (Exception e) {
       e.printStackTrace();
       msg = "修改密码失败!";
       type = 2;
       // 提示信息
       // Flash.current().success(RESET_PASSWORD_FAILURE);
     }
   } else {
     msg = "原始密码错误!";
     type = 3;
   }
   getRequest().setAttribute("type", type);
   getRequest().setAttribute("msg", msg);
   return "update_password";
 }
Beispiel #2
0
  /**
   * 重置密码
   *
   * @return
   */
  public String resetPassword() {

    try {
      User user = this.userManager.getById(id);
      // 默认重置为000000
      user.setPassword("111111");
      this.userManager.save(user);

      // 提示信息
      Flash.current().success(RESET_PASSWORD_SUCCESS);
    } catch (Exception e) {
      e.printStackTrace();

      // 提示信息
      Flash.current().success(RESET_PASSWORD_FAILURE);
    }
    return LIST_ACTION;
  }