From f2fa318161407b936f70aa3b918dd38f24ea9a88 Mon Sep 17 00:00:00 2001 From: yzh <snbbt@21cn.com> Date: 星期一, 13 六月 2022 07:08:28 +0800 Subject: [PATCH] 数据字典表相关功能 系统账号管理优化 订单管理 API账号管理 客户信息管理 --- web/web/SysUser.ashx | 99 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 83 insertions(+), 16 deletions(-) diff --git a/web/web/SysUser.ashx b/web/web/SysUser.ashx index f1bae60..d5590f4 100644 --- a/web/web/SysUser.ashx +++ b/web/web/SysUser.ashx @@ -31,7 +31,10 @@ return this.UpdatePermission(context); case "updateStatus": return this.UpdateStatus(context); - + //淇敼瀵嗙爜 + case "updatePwd": + return UpdatePwd(context); + default: throw new Exception("Invalid Action=" + @string); } @@ -102,8 +105,11 @@ 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)) @@ -136,17 +142,24 @@ 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; @@ -156,6 +169,12 @@ 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 @@ -164,7 +183,25 @@ 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) "璐︽埛淇濆瓨鎴愬姛锛�"); } @@ -177,10 +214,40 @@ 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)"淇敼瀵嗙爜鎴愬姛锛�"); + } } -- Gitblit v1.9.1