/// <summary> /// 用户集合操作完成后事件 /// </summary> /// <param name="operateType">操作类型</param> /// <param name="ts">用户对象集合</param> /// <param name="result">操作结果</param> /// <param name="currUser">当前用户</param> /// <param name="otherParams">其他参数</param> public void OperateCompeletedHandles(ModelRecordOperateType operateType, List <Sys_User> ts, bool result, UserInfo currUser, object[] otherParams = null) { if (operateType == ModelRecordOperateType.Add && result) { //新增用户后初始化用户密码为 username+'_'+123456 string errMsg = string.Empty; foreach (Sys_User t in ts) { if (string.IsNullOrEmpty(t.PasswordHash)) { string pwd = string.Format("{0}_123456", t.UserName); bool rs = UserOperate.ModifyPassword(t.Id, pwd, out errMsg); if (rs) { new UserOperateHandleFactory().AfterRegiterUser(t.UserName, pwd); } } } } if (operateType == ModelRecordOperateType.Del && result) { foreach (Sys_User t in ts) { new UserOperateHandleFactory().AfterDeleteUser(t.UserName); } } }
public JsonResult ChangePwdNoLogin() { if (_Request == null) { _Request = Request; } Guid uid = _Request.QueryEx("uid").ObjToGuid(); if (uid == Guid.Empty || string.IsNullOrEmpty(UserOperate.GetUserNameByUserId(uid))) { return(Json(new ReturnResult() { Success = false, Message = "用户ID不存在!" })); } string pwd1 = _Request.QueryEx("pwd1").ObjToStr(); string pwd2 = _Request.QueryEx("pwd2").ObjToStr(); if (string.IsNullOrEmpty(pwd1.Trim())) { return(Json(new ReturnResult() { Success = false, Message = "新密码不能为空!" })); } if (pwd1.Length < 5 || pwd1.Length > 20) { return(Json(new ReturnResult() { Success = false, Message = "密码长度为5-20个字符!" })); } if (pwd1 != pwd2) { return(Json(new ReturnResult() { Success = false, Message = "两次密码输入不一致!" })); } string errMsg = string.Empty; bool rs = UserOperate.ModifyPassword(uid, pwd1, out errMsg); return(Json(new ReturnResult() { Success = rs, Message = errMsg })); }
/// <summary> /// 修改密码 /// </summary> /// <returns></returns> public JsonResult ChangePwd() { if (_Request == null) { _Request = Request; } SetRequest(_Request); UserInfo currUser = GetCurrentUser(_Request); if (currUser == null) { return(Json(new ReturnResult() { Success = false, Message = "您未登录系统或登录时间过长,请重新登录系统后再修改密码!" })); } string errMsg = string.Empty; string oldPwd = _Request.QueryEx("oldPwd").ObjToStr(); string newPwd = _Request.QueryEx("newPwd").ObjToStr(); UserInfo tempUserInfo = UserOperate.GetUserInfo(currUser.UserName, oldPwd, out errMsg); if (tempUserInfo == null) { return(Json(new ReturnResult() { Success = false, Message = "您当前登录密码输入不正确,请重新输入!" })); } bool rs = UserOperate.ModifyPassword(currUser.UserId, newPwd, out errMsg); if (rs) { CommonOperate.ExecuteUserOperateHandleMethod("AfterChangePwd", new object[] { currUser.UserName, oldPwd, newPwd }); } return(Json(new ReturnResult() { Success = rs, Message = errMsg })); }