Administrator 4 years ago
parent
commit
74ea6de580

+ 5 - 2
Code/UC/UC.Api/Controllers/SMSController.cs

@@ -41,15 +41,17 @@ namespace UC.Api.Controllers
             }
             var key = query.Type == PhoneCodeTypeEnum.登陆验证 ? $"{CacheConstant.LoginPhoneCode}_{query.Phone}" :
                  query.Type == PhoneCodeTypeEnum.修改验证 ? $"{CacheConstant.EditPhoneCode}_{query.Phone}" :
+                 query.Type==PhoneCodeTypeEnum.忘记密码?$"{CacheConstant.ForgotPwdPhoneCode}_{query.Phone}":
                  $"{CacheConstant.RegisterPhoneCode}_{query.Phone}";
             var viKey = query.Type == PhoneCodeTypeEnum.登陆验证 ? $"{CacheConstant.LoginPhoneCode}_{query.Phone}_Cf" :
                 query.Type == PhoneCodeTypeEnum.修改验证 ? $"{CacheConstant.EditPhoneCode}_{query.Phone}_Cf" :
+                query.Type == PhoneCodeTypeEnum.忘记密码 ? $"{CacheConstant.ForgotPwdPhoneCode}_{query.Phone}_Cf" :
                  $"{CacheConstant.RegisterPhoneCode}_{query.Phone}_Cf";
             if (!cache.GetCache<string>(viKey).IsEmpty())
             {
                 Accepted("验证码已发送,若未收到,请1分钟后再次尝试!");
             }
-            var code = OtherHelper.RandomInt(6).Select(p => p.ToString()).Join("");
+            var code =OtherHelper.RandomInt(6).Select(p => p.ToString()).Join("");
             if (query.Type == PhoneCodeTypeEnum.注册验证 && bll_com.FindEntity<Users_Login>(p => p.UserName == query.Phone) != null)
                 Accepted("该手机号码已注册账户信息!");
             await Task.Run(() =>
@@ -86,12 +88,13 @@ namespace UC.Api.Controllers
                     text = CacheConstant.EditPhoneCode + "_" + query.Phone;
                     break;
                 case PhoneCodeTypeEnum.注册验证:
-                    text = CacheConstant.EditPhoneCode + "_" + query.Phone;
+                    text = CacheConstant.RegisterPhoneCode + "_" + query.Phone;
                     break;
                 case PhoneCodeTypeEnum.忘记密码:
                     text = CacheConstant.ForgotPwdPhoneCode + "_" + query.Phone;
                     break;
             }
+            var i= this.cache.GetCache<string>(text);
             return this.cache.GetCache<string>(text) == query.Code;
         }
     }

+ 28 - 26
Code/UC/UC.Api/Controllers/UsersController.cs

@@ -50,7 +50,7 @@ namespace UC.Api.Controllers
                     if (IsExistUserName(entity.UserName))
                         Accepted("该手机号已注册!");
                     var key = $"{CacheConstant.RegisterPhoneCode}_{entity.UserName}";
-                    var code = "123456";//cache.GetCache<string>(key);
+                    var code = cache.GetCache<string>(key);//"123456"
                     if (code != entity.PhoneCode)
                     {
                         Accepted("验证码已过期,请重新获取!");
@@ -63,7 +63,7 @@ namespace UC.Api.Controllers
                         Password = password,
                         CreateTime = DateTime.Now,
                         UserName = entity.UserName,
-                        NickName = $"新用户" + NewGetNickName(),
+                        NickName = $"新用户"+entity.UserName.Substring(6,4) ,//+ NewGetNickName(),
                         Phone = entity.UserName,
                         Logo = entity.Logo,
                         LoginCode = bll_user.LoginCode(entity.UserName),
@@ -84,20 +84,19 @@ namespace UC.Api.Controllers
                     //IsAddUp为1直接新增,否则修改
                     if (entity.IsAddUp == 1)
                     {
-
-                        //从缓存中获取验证码
-                        var qqcode = "123456";//cache.GetCache<string>(key);
-                        if (qqcode != entity.PhoneCode)
-                        {
-                            Accepted("验证码已过期,请重新获取!");
-                        }
-
                         var model = bll_com.FindEntity<Users_Login>(p => p.Qq == entity.OpenCode);
                         if (model != null)
                         {
                             Accepted("该QQ已注册!");
                         }
                         var qqkey = $"{CacheConstant.RegisterPhoneCode}_{entity.UserName}";
+                        //从缓存中获取验证码
+                        var qqcode = cache.GetCache<string>(qqkey); //"123456";
+                        if (qqcode != entity.PhoneCode)
+                        {
+                            Accepted("验证码已过期,请重新获取!");
+                        }
+
                         var qqpwdsalt = Md5Helper.CheckRandomCode();
                         userModel = new Users_Login
                         {
@@ -105,7 +104,7 @@ namespace UC.Api.Controllers
                             CreateTime = DateTime.Now,
                             UserName = entity.UserName,
                             Qq = entity.OpenCode,
-                            NickName = $"新用户" + NewGetNickName(),
+                            NickName = $"新用户" + entity.UserName.Substring(6, 4),
                             Logo = entity.Logo,
                             LoginCode = bll_user.LoginCode(entity.UserName),
                             Remark = NewGetNickName()
@@ -118,8 +117,9 @@ namespace UC.Api.Controllers
                     }
                     else
                     {
+                        var qqkey = $"{CacheConstant.RegisterPhoneCode}_{entity.UserName}";
                         //从缓存中获取验证码
-                        var qqcode = "123456";//cache.GetCache<string>(key);
+                        var qqcode = cache.GetCache<string>(qqkey);//"123456";
                         if (qqcode != entity.PhoneCode)
                         {
                             Accepted("验证码已过期,请重新获取!");
@@ -136,25 +136,26 @@ namespace UC.Api.Controllers
                     if (entity.IsAddUp == 1)
                     {
                         //从缓存中获取验证码
-                        var qqcode = "123456";//cache.GetCache<string>(key);
-                        if (qqcode != entity.PhoneCode)
-                        {
-                            Accepted("验证码已过期,请重新获取!");
-                        }
+
                         var wxmodel = bll_com.FindEntity<Users_Login>(p => p.WeChat == entity.OpenCode);
                         if (wxmodel != null)
                         {
                             Accepted("该微信号已注册!");
                         }
                         var wxkey = $"{CacheConstant.RegisterPhoneCode}_{entity.UserName}";
+                        var wxcode = cache.GetCache<string>(wxkey);//"123456";
+                        if (wxcode != entity.PhoneCode)
+                        {
+                            Accepted("验证码已过期,请重新获取!");
+                        }
                         var wxpwdsalt = Md5Helper.CheckRandomCode();
                         userModel = new Users_Login
                         {
                             PwdSalt = wxpwdsalt,
                             CreateTime = DateTime.Now,
-                            UserName=entity.OpenCode,
+                            UserName = entity.OpenCode,
                             WeChat = entity.OpenCode,
-                            NickName = $"新用户" + NewGetNickName(),
+                            NickName = $"新用户" + entity.UserName.Substring(6, 4),//NewGetNickName(),
                             Logo = entity.Logo,
                             LoginCode = bll_user.LoginCode(entity.UserName),
                             Remark = NewGetNickName()
@@ -168,8 +169,9 @@ namespace UC.Api.Controllers
                     else
                     {
                         //从缓存中获取验证码
-                        var qqcode = "123456";//cache.GetCache<string>(key);
-                        if (qqcode != entity.PhoneCode)
+                        var wxkey = $"{CacheConstant.RegisterPhoneCode}_{entity.UserName}";
+                        var wxcode = cache.GetCache<string>(wxkey);//"123456";
+                        if (wxcode != entity.PhoneCode)
                         {
                             Accepted("验证码已过期,请重新获取!");
                         }
@@ -229,7 +231,7 @@ namespace UC.Api.Controllers
                     if (userModel == null)
                         Accepted("您的账号不存在,请前往注册页面,注册您的账户!");
                     var key = $"{CacheConstant.LoginPhoneCode}_{query.UserName}";
-                    var code = "123456";//cache.GetCache<string>(key);
+                    var code = cache.GetCache<string>(key);//"123456";
                     if (code != query.Password)
                     {
                         Accepted("验证码已过期,请重新获取!");
@@ -317,7 +319,7 @@ namespace UC.Api.Controllers
                         Accepted("手机号码错误!");
                     }
                     var bdkey = $"{CacheConstant.EditPhoneCode}_{model.Content}";
-                    if (model.Content2 != "123456") //cache.GetCache<string>(bdkey)
+                    if (model.Content2 != cache.GetCache<string>(bdkey)) //cache.GetCache<string>(bdkey)
                     {
                         FilesHelper.LogBD(model.TryToJson(), "code");
                         Accepted("验证码错误!");
@@ -336,7 +338,7 @@ namespace UC.Api.Controllers
                         Accepted("已存在该手机号账户!");
                     }
                     var key = $"{CacheConstant.EditPhoneCode}_{model.Content}";
-                    if (model.Content2 != "123456")//cache.GetCache<string>(key)
+                    if (model.Content2 != cache.GetCache<string>(key))//cache.GetCache<string>(key)
                     {
                         FilesHelper.LogBD(model.TryToJson(), "code");
                         Accepted("验证码错误!");
@@ -379,8 +381,8 @@ namespace UC.Api.Controllers
                     {
                         Accepted("密码不能为空!");
                     }
-                    var key1 = $"{CacheConstant.EditPhoneCode}_{model.Content}";
-                    if (model.Content2 != "123456")//cache.GetCache<string>(key1)
+                    var key1 = $"{CacheConstant.ForgotPwdPhoneCode}_{model.Content}";
+                    if (model.Content2 != cache.GetCache<string>(key1))//cache.GetCache<string>(key1)
                     {
                         FilesHelper.LogBD(model.TryToJson(), "code");
                         Accepted("验证码错误!");