Beispiel #1
0
 private boolean checkUser() {
   boolean result = true;
   if (user.getUsername() == null || "".equals(user.getUsername().trim())) {
     msg = "用户名不能为空!";
     result = false;
   } else if (user.getPassword() == null || "".equals(user.getPassword().trim())) {
     msg = "密码不能为空!";
     result = false;
   } else if (this.repassword == null || "".equals(this.repassword)) {
     msg = "请确认密码!";
     result = false;
   } else if (this.repassword.trim().equals(user.getPassword().trim())) {
     msg = "两次输入密码不一致";
     result = false;
   }
   return result;
 }
Beispiel #2
0
  /**
   * 修改密码Action
   *
   * @return
   */
  public String changePassword() {
    log.debug("===> invoke changePassword Action");
    // 判断用户名是否为空
    if (this.user.getUsername() == null || "".equals(this.user.getUsername())) {
      msg = "用户名不能为空!";
      ActionContext.getContext().getSession().put("msg", msg);
      return INPUT;
    }

    // 判断密码是否为空
    if (this.user.getPassword() == null || "".equals(this.user.getPassword())) {
      msg = "密码不能为空!";
      ActionContext.getContext().getSession().put("msg", msg);
      return INPUT;
    }

    // 判断确认密码是否为空
    if (this.repassword == null || "".equals(this.repassword)) {
      msg = "请确认密码!";
      ActionContext.getContext().getSession().put("msg", msg);
      return INPUT;
    }

    // 判断两次输入密码是否一致
    if (!this.repassword.equals(this.user.getPassword())) {
      msg = "两次输入密码不一致!";
      ActionContext.getContext().getSession().put("msg", msg);
      return INPUT;
    }

    this.user = userService.findUserByName(user.getUsername()); // 通过用户名查找到用户信息
    if (user != null) {
      user.setPassword(this.repassword);
      // 修改用户密码
      this.user = this.userService.changePassword(user);
      if (this.user != null) {
        msg = "修改密码成功";
        ServletActionContext.getRequest().getSession().setAttribute("msg", msg);
        ServletActionContext.getRequest().getSession().setAttribute("user", user);
        return SUCCESS;
      } else {
        msg = "修改密码失败";
        ServletActionContext.getRequest().getSession().setAttribute("msg", msg);
        return INPUT;
      }
    } else {
      return INPUT;
    }
  }
Beispiel #3
0
  public String update() {
    ActionContext.getContext().getSession().remove("updateUser");
    if (!checkUser()) {
      this.user = userService.findUserByName(user.getUsername()); // 通过用户名查找用户
      if (user != null) {
        user.setEnabled(this.enabled); // 设置查找出来用户的激活性
        user.setDescription(this.description); // 设置查找出来的用户的描述信息
        user.setPassword(this.repassword); // 设置查找出来的用户的密码

        user = userService.changePassword(user); // 修改用户信息
        if (user != null) {
          msg = "修改成功!";
        } else {
          msg = "修改失败!";
        }
      }
    }

    ActionContext.getContext().getSession().put("msg", msg);
    ActionContext.getContext().getSession().put("userAction", 2); // userAction:2 表示修改用户信息
    return SUCCESS;
  }