Ejemplo n.º 1
0
  public String execute() {

    User selectUser = null; // 用来接收查询的用户信息

    // 加密密码
    oldpassword = MD5.GetMD5Code(oldpassword);
    user.setPassword(MD5.GetMD5Code(user.getPassword()));
    newpassword2 = MD5.GetMD5Code(newpassword2);

    if (user.getPassword().equals(newpassword2)) { // 判断两次的密码是否一致
      if (um.getByID(user.getUserID()) != null) {
        selectUser = um.getByID(user.getUserID()); // 获取当前用户密码
        if (selectUser.getPassword().equals(oldpassword)) { // 如果当前用户密码和用户所填写的密码相同,则修改密码

          um.updateUser(user, 1);

          ActionContext ctx = ActionContext.getContext();
          Map session = ctx.getSession();
          session.clear();

          setTips("修改密码成功");
          setRedirectUrl("/CMS/user/Login");
          return "success";
        } else {
          setTips("原密码错误");
          setRedirectUrl("/CMS/user/UpdatePassword");
          return "error";
        }
      }
    } else {
      setTips("两次输入的密码不一致");
      setRedirectUrl("/CMS/user/UpdatePassword");
      return "error";
    }

    setTips("修改失败");
    setRedirectUrl("/CMS/user/UpdatePassword");
    return "error";
  }
Ejemplo n.º 2
0
  public String execute() {

    // 获取用户信息
    User user = um.getByID(getUserID());

    // 重置密码,新密码8888
    user.setPassword(com.cms.others.MD5.GetMD5Code("8888"));

    // 判断是否重置成功
    if (um.updateUser(user, 0)) {
      setTips("重置成功");
      setRedirectUrl("/CMS/user/UserManage");
      return "success";
    }

    setTips("重置失败");
    setRedirectUrl("/CMS/user/UserManage");
    return "error";
  }