/// <summary> /// 密码修改 /// </summary> /// <returns></returns> private string AlterPwd() { string before = Request.Form.Get("pwd_before"); string news = Request.Form.Get("pwd_news"); string newsto = Request.Form.Get("pwd_newsTo"); //验证旧密码 if (before == null || string.IsNullOrEmpty(before)) { return(ReturnString.JsonToString(Prompt.error, "旧密码不能为空", "pwd_before")); } if (!Regex.IsMatch(before, @"^(\w){6,20}$")) { return(ReturnString.JsonToString(Prompt.error, "旧密码输入不正确", "pwd_before")); } //验证新密码 if (news == null || string.IsNullOrEmpty(news)) { return(ReturnString.JsonToString(Prompt.error, "新密码不能为空", "pwd_news")); } if (!Regex.IsMatch(news, @"^(\w){6,20}$")) { return(ReturnString.JsonToString(Prompt.error, "新密码输入不正确", "pwd_news")); } //验证新密码与旧密码相同 if (!news.Equals(newsto)) { return(ReturnString.JsonToString(Prompt.error, "新密码与确认密码不一致!", "pwd_newsTo")); } //判断新密码与旧密码是否相同 if (before.Equals(news)) { return(ReturnString.JsonToString(Prompt.error, "旧密码与新密码相同无须修改!", "pwd_news")); } EDRS.BLL.XT_ZZJG_RYBM bll = new EDRS.BLL.XT_ZZJG_RYBM(this.Request); string msg = string.Empty; List <EDRS.Model.XT_QX_JSBM> jsbmList; EDRS.Model.XT_ZZJG_RYBM rybm = bll.UserLogin(UserInfo.DWBM, UserInfo.DLBM, before, out jsbmList, out msg); if (rybm != null) { rybm.KL = MD5Encrypt.Encrypt(news).ToLower(); if (bll.Update(rybm)) { return(ReturnString.JsonToString(Prompt.win, "密码修改成功,重新登录生效!", null)); } return(ReturnString.JsonToString(Prompt.error, "密码修改失败!", null)); } else { return(ReturnString.JsonToString(Prompt.error, msg, null)); } }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> private string UserLogin() { //List<FromValue> list = JsonConvert.DeserializeObject<List<FromValue>>(data); //if (list == null || list.Count == 0) // return ReturnString.JsonToString(Prompt.error, "参数错误", ""); string type = ""; string name = ""; string value = ""; if (string.IsNullOrEmpty(Request.Form.Get("tree_select_id")) && string.IsNullOrEmpty(Request.Form.Get("tree_select_hid"))) { return(ReturnString.JsonToString(Prompt.error, "请先选择单位", "tree_select")); } if (string.IsNullOrEmpty(Request.Form.Get("txtUser"))) { return(ReturnString.JsonToString(Prompt.error, "用户名不能为空", "txtUser")); } if (!Regex.IsMatch(Request.Form.Get("txtUser").ToString(), @"^(\w){1,20}$")) { return(ReturnString.JsonToString(Prompt.error, "用户名输入不正确", "txtUser")); } if (string.IsNullOrEmpty(Request.Form.Get("txtPwd"))) { return(ReturnString.JsonToString(Prompt.error, "密码不能为空", "txtPwd")); } if (!Regex.IsMatch(Request.Form.Get("txtPwd").ToString(), @"^(\w){6,20}$")) { return(ReturnString.JsonToString(Prompt.error, "密码输入不正确", "txtPwd")); } if (string.IsNullOrEmpty(Request.Form.Get("tree_select_id"))) { type = Request.Form.Get("tree_select_hid"); } else { type = Request.Form.Get("tree_select_id").ToString(); } name = Request.Form.Get("txtUser").ToString(); value = Request.Form.Get("txtPwd").ToString(); //else if (fv.Name == "txtVCode") //{ // if (string.IsNullOrEmpty(fv.Value.ToString().Trim())) // return ReturnString.JsonToString(Prompt.error, "验证码不能为空", "txtVCode"); // if (HttpContext.Current.Session["ValidateCode"].ToString().ToLower() != fv.Value.ToString().ToLower()) // return ReturnString.JsonToString(Prompt.error, "验证码错误", "txtVCode"); //} //} //1bbd886460827015e5d605ed44252251 8个1 [a-zA-Z]\w{1,3} EDRS.BLL.XT_ZZJG_RYBM bll = new EDRS.BLL.XT_ZZJG_RYBM(request); string msg = string.Empty; List <EDRS.Model.XT_QX_JSBM> jsbmList; try { EDRS.BLL.XT_ZZJG_DWBM dwbmBll = new EDRS.BLL.XT_ZZJG_DWBM(request); EDRS.Model.XT_ZZJG_DWBM dwbmmodel = dwbmBll.GetModel(type); if (dwbmmodel == null) { return(ReturnString.JsonToString(Prompt.error, "选择单位不存在,请重新选择", null)); } EDRS.Model.XT_ZZJG_RYBM rybm = bll.UserLogin(type, name, value, out jsbmList, out msg); if (rybm != null) { HttpContext.Current.Session["user"] = rybm; HttpContext.Current.Session["userDwbm"] = dwbmmodel; if (jsbmList != null) { HttpContext.Current.Session["userRole"] = jsbmList; } HttpCookie cookie = new HttpCookie("login"); //cookie.Values[EDRS.Common.DEncrypt.DESEncrypt.Encrypt("UnitOption", "UnitOption")] = EDRS.Common.DEncrypt.DESEncrypt.Encrypt(rybm.DWBM, "UnitOption"); //cookie.Values[EDRS.Common.DEncrypt.DESEncrypt.Encrypt("UserName", "UserName")] = EDRS.Common.DEncrypt.DESEncrypt.Encrypt(rybm.DLBM, "UserName"); cookie.Values["UnitOption"] = rybm.DWBM; cookie.Values["UnitOptionName"] = HttpUtility.UrlEncode(rybm.DWMC, Encoding.UTF8); cookie.Values["UserName"] = HttpUtility.UrlEncode(rybm.DLBM, Encoding.UTF8); cookie.Expires = DateTime.MaxValue; HttpContext.Current.Response.Cookies.Add(cookie); OperateLog.AddLog(OperateLog.LogType.登录系统, msg, rybm, jsbmList, request); return(ReturnString.JsonToString(Prompt.win, msg, null)); } else { rybm = new EDRS.Model.XT_ZZJG_RYBM(); XT_ZZJG_DWBM dwbmbll = new XT_ZZJG_DWBM(request); EDRS.Model.XT_ZZJG_DWBM dwbm = dwbmbll.GetModel(type); if (dwbm != null) { rybm.MC = name; rybm.DWBM = dwbm.DWBM; rybm.DWMC = dwbm.DWMC; } OperateLog.AddLog(OperateLog.LogType.登录系统, msg, rybm, jsbmList, request); return(ReturnString.JsonToString(Prompt.error, msg, null)); } } catch (Exception ex) { msg = Regex.Replace(ex.Message, "[\r\n\"]", ""); return(ReturnString.JsonToString(Prompt.error, msg, null)); } }