| | |
| | | return this.UpdatePermission(context); |
| | | case "updateStatus": |
| | | return this.UpdateStatus(context); |
| | | |
| | | //修改密码 |
| | | case "updatePwd": |
| | | return UpdatePwd(context); |
| | | |
| | | default: |
| | | throw new Exception("Invalid Action=" + @string); |
| | | } |
| | |
| | | int num = 0; |
| | | if (string.IsNullOrEmpty(string1) || !Regex.IsMatch(string1, "\\w{3,}")) |
| | | throw new ArgumentException("账户至少3位可见字符,请重新输入!"); |
| | | if (string.IsNullOrEmpty(string2) || string2.Length < 6) |
| | | throw new ArgumentException("账户密码至少6位,请重新输入!"); |
| | | if(int1<= 0 ) |
| | | { |
| | | if (string.IsNullOrEmpty(string2) || string2.Length < 6) |
| | | throw new ArgumentException("账户密码至少6位,请重新输入!"); |
| | | } |
| | | if (string.IsNullOrEmpty(userName)) |
| | | throw new ArgumentException("账户名称不能为空,请输入!"); |
| | | if (string.IsNullOrEmpty(userType)) |
| | |
| | | sysUser.UserName = userName; |
| | | sysUser.UserType = string.IsNullOrEmpty(userType) ? 0 : int.Parse(userType); |
| | | sysUser.CreateTime = DateTime.Now; |
| | | if (int1 > 0) |
| | | { |
| | | SysUser userInfo = this._Dao.GetUserInfo(int1); |
| | | sysUser.Password = userInfo.Password == string2 ? userInfo.Password : DataHelper.MD5Hex(string2); |
| | | sysUser.IsEncryption = userInfo.Password == string2 ? userInfo.IsEncryption : 1; |
| | | } |
| | | else |
| | | { |
| | | sysUser.Password = DataHelper.MD5Hex(string2); |
| | | sysUser.IsEncryption = 1; |
| | | } |
| | | |
| | | /** |
| | | //获取唯一标识符 |
| | | string salt = DataConverter.getRandom(6); |
| | | if (int1 > 0) |
| | | { |
| | | SysUser userInfo = this._Dao.GetUserInfo(int1); |
| | | sysUser.Password = userInfo.Password == string2 ? userInfo.Password : DataHelper.MD5Hex(string2); |
| | | sysUser.IsEncryption = userInfo.Password == string2 ? userInfo.IsEncryption : 1; |
| | | } |
| | | else |
| | | { |
| | | string2 += salt; |
| | | sysUser.Password = DataHelper.MD5Hex(string2); |
| | | sysUser.IsEncryption = 1; |
| | | sysUser.Salt = salt; |
| | | }**/ |
| | | |
| | | sysUser.Email = string3; |
| | | sysUser.Mobile = string4; |
| | | sysUser.MobileFlag = int3; |
| | |
| | | if (int1 > 0) |
| | | { |
| | | context.CheckRight("1042", FailedOperation.PromptOnly); |
| | | if (int1 > 0) |
| | | { |
| | | SysUser userInfo = this._Dao.GetUserInfo(int1); |
| | | sysUser.IsEncryption = userInfo.Password == string2 ? userInfo.IsEncryption : 1; |
| | | } |
| | | //edit:yangzh by 20220612 修改时不更新密码 |
| | | this._Dao.Update(sysUser); |
| | | } |
| | | else |
| | |
| | | if (this._Dao.Exists(string1)) |
| | | throw new ArgumentException("账户已经存在,请重新输入!"); |
| | | |
| | | |
| | | string password = ""; |
| | | if(int1> 0 ) |
| | | { |
| | | throw new ArgumentException("密码不能为空,请重新输入!"); |
| | | } |
| | | |
| | | //获取唯一标识符 |
| | | string salt = DataConverter.getRandom(6); |
| | | |
| | | string2 += salt; |
| | | password = DataHelper.MD5Hex(string2); |
| | | |
| | | sysUser.IsEncryption = 1; |
| | | sysUser.Salt = salt; |
| | | sysUser.Password = password; |
| | | |
| | | this._Dao.Add(sysUser); |
| | | |
| | | } |
| | | return new JsonPageResult(true, (object) "账户保存成功!"); |
| | | } |
| | |
| | | int status = context.GetInt("status"); |
| | | |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.UserID = userId; |
| | | sysUser.Status = status; |
| | | sysUser.UserID = userId; |
| | | sysUser.Status = status; |
| | | this._Dao.UpdateStatus(sysUser); |
| | | return new JsonPageResult(true, "更新信息状态成功!"); |
| | | |
| | | } |
| | | |
| | | //修改密码 |
| | | private JsonPageResult UpdatePwd(PageContext<Model.SysUser> context) |
| | | { |
| | | string account = context.GetString("account"); |
| | | string newPwd = context.GetString("newPwd"); |
| | | int userID = 0; |
| | | |
| | | if (string.IsNullOrEmpty(account)) |
| | | { |
| | | throw new ArgumentException("系统账号参数异常!"); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(newPwd) || !System.Text.RegularExpressions.Regex.IsMatch(newPwd, @"[a-zA-Z0-9]{4,10}")) |
| | | { |
| | | throw new ArgumentException("登录密码不能为空,且必须为4-10位英文或数字字符组合!"); |
| | | } |
| | | string salt = ""; |
| | | SysUser sysUser = _Dao.GetUser(account); |
| | | |
| | | salt = sysUser.Salt==null? "": sysUser.Salt.ToString(); |
| | | newPwd += salt; |
| | | |
| | | //密码MD5加密, |
| | | newPwd = DataHelper.MD5Hex(newPwd); |
| | | |
| | | _Dao.UpdatePwd(account, newPwd ); |
| | | |
| | | return new JsonPageResult(true, (object)"修改密码成功!"); |
| | | } |
| | | } |