private PageBase.ManagerUserEntity GetUserInfo(Entity.Sys_User user) { PageBase.ManagerUserEntity entity = new PageBase.ManagerUserEntity(); entity.guid = user.Guid; entity.username = user.UserName; entity.name = user.Name; entity.role = user.RoleAuthorize; entity.department = (int)user.Department; entity.isSuperUser = user.IsSuperUser; entity.phone = user.Phone; entity.pic = user.Pic; return(entity); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string username = context.Request.Form["username"]; string password = context.Request.Form["password"]; string remember = context.Request.Form["remember"]; DataAccess.Sys_User da = new DataAccess.Sys_User(); DataTable dt = da.GetList("UserName='******' and IsDelete=0").Tables[0]; if (dt.Rows.Count == 0) { context.Response.Write(JsonConvert.SerializeObject(new Data("用户名不存在.", ""))); } else { Entity.Sys_User model = da.DataRowToModel(dt.Rows[0]); string cookie = ZWL.ObjectOperation.CookieHelper.GetCookie("pw"); if (cookie == password) { if (password == model.Password) { SaveCookie(username, password, remember); PageBase.CommonObject.ManagerUserInfo = GetUserInfo(model); context.Response.Write(JsonConvert.SerializeObject(new Data("", ""))); } else { context.Response.Write(JsonConvert.SerializeObject(new Data("密码错误.", ""))); } } else { if (ZWL.Encrypt.AbstractHelper.EncryptMD5(password) == model.Password) { SaveCookie(username, password, remember); PageBase.CommonObject.ManagerUserInfo = GetUserInfo(model); context.Response.Write(JsonConvert.SerializeObject(new Data("", ""))); } else { context.Response.Write(JsonConvert.SerializeObject(new Data("密码错误.", ""))); } } } }
public static void SendPwdMessage(Entity.Sys_User user, string pwd) { try { if (bool.Parse(ZWL.GeneralHelper.GetSettingByKey("IsSend"))) { DataTable dt = new DataTable(); dt.Columns.Add("Guid"); dt.Columns.Add("AgentPhone"); dt.Columns.Add("SendTxt"); dt.Rows.Add(Guid.NewGuid(), user.Phone, string.Format("制卡系统(管理端)用户{0}({1}),您的初始随机密码为{2},请及时登录系统修改密码。", user.UserName, user.Name, pwd)); IRequestSend(dt); } } catch { return; } }
public void ProcessRequest(HttpContext context) { try { context.Response.ContentType = "text/plain"; Entity.Sys_User user = new Entity.Sys_User(); DataAccess.Sys_User da = new DataAccess.Sys_User(); switch (context.Request.Form["type"]) { case "add": user.Guid = Guid.NewGuid().ToString(); user.UserName = context.Request.Form["userName"]; if (da.GetList(string.Format("UserName='******'", user.UserName)).Tables[0].Rows.Count > 0) { context.Response.Write("添加用户信息失败!用户名已存在!"); return; } user.Name = context.Request.Form["trueName"]; string encrpyPwd = da.RndPwd(8); user.Password = ZWL.Encrypt.AbstractHelper.EncryptMD5(encrpyPwd); user.Phone = context.Request.Form["phoneNum"]; user.Department = int.Parse(context.Request.Form["department"]); user.IsDelete = false; user.IsSuperUser = false; user.Pic = "avatar.png"; user.CreateTime = DateTime.Now; if (da.Add(user)) { DataAccess.CardCenterHelper.SendPwdMessage(user, encrpyPwd); context.Response.Write(""); } else { context.Response.Write("添加用户信息失败!入库出错,请联系管理员!"); } break; case "edit": user = da.GetModel(context.Request.Form["Guid"]); user.Name = context.Request.Form["trueName"]; user.Phone = context.Request.Form["phoneNum"]; user.Department = int.Parse(context.Request.Form["department"]); if (da.Update(user)) { context.Response.Write(""); } else { context.Response.Write("修改用户信息失败!入库出错,请联系管理员!"); } break; case "reset": user = da.GetModel(context.Request.Form["Guid"]); string resetPwd = da.RndPwd(8); user.Password = ZWL.Encrypt.AbstractHelper.EncryptMD5(resetPwd); if (da.Update(user)) { DataAccess.CardCenterHelper.SendPwdMessage(user, resetPwd); context.Response.Write(""); } else { context.Response.Write("重置密码失败!入库出错,请联系管理员!"); } break; case "pwd": user = da.GetModel(context.Request.Form["Guid"]); if (user.Password == ZWL.Encrypt.AbstractHelper.EncryptMD5(context.Request.Form["oldPwd"])) { user.Password = ZWL.Encrypt.AbstractHelper.EncryptMD5(context.Request.Form["newPwd"]); if (da.Update(user)) { context.Response.Write(""); } else { context.Response.Write("修改失败!入库出错,请联系管理员!"); } } else { context.Response.Write("旧密码错误,修改失败!"); } break; default: context.Response.Write("参数错误!"); break; } } catch (Exception ex) { context.Response.Write("操作失败!请联系管理员!" + ex.ToString()); } }