Browse Source

用户注册时 验证 短信验证码 并完善 相关提示

lifa 1 year ago
parent
commit
39c6192f06

+ 36 - 4
src/platform/ZhonTai.Admin/Services/DiTuiAPI/DiTuiAPIService.cs

@@ -201,16 +201,48 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         {
             var platform = _httpContextAccessor.HttpContext.Request.Headers["platform"];
 
+            if(input.Password != input.PasswordCheck && !string.IsNullOrEmpty(input.Password))
+            {
+                throw ResultOutput.Exception($"两次输入密码不一致");
+            }
             if (string.IsNullOrEmpty(input.InvitCode))
             {
                 throw ResultOutput.Exception($"邀请码不可为空");
             }
+            if (string.IsNullOrEmpty(input.Phone))
+            {
+                throw ResultOutput.Exception($"手机号不可为空");
+            }
+
+            if (string.IsNullOrEmpty(input.VCode))
+            {
+                throw ResultOutput.Exception($"短信验证码不可为空");
+            }
+            var vCodeResult = await _smsRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
+                .Where(a => a.Mobile == input.Phone && a.Vcode == input.VCode && a.CreatedTime >= DateTime.Now.AddMinutes(-10) && a.Status == 0)
+                .OrderByDescending(a => a.CreatedTime)
+                .FirstAsync();
+            if(vCodeResult is null)
+            {
+                throw ResultOutput.Exception($"短信验证码不正确");
+            }
+            else
+            {
+                SmsEntity smsEntity = new SmsEntity();
+                Mapper.Map(vCodeResult, smsEntity);
+
+                smsEntity.Status = 1;
+                //vCodeResult.Status = 1;
+                var updateResult = _smsRepository.UpdateDiy.DisableGlobalFilter(FilterNames.Tenant).SetSource(smsEntity).ExecuteAffrowsAsync();
+
+            }
+
             var org = await _orgRepository.Select.Where(a=> a.Code == platform).DisableGlobalFilter()
                 .FirstAsync(a => new { a.Name, a.TenantId });
 
             Expression<Func<PlatformUserEntity, bool>> where = (a => a.Phone == input.Phone);
-            where = where.Or(input.Phone.NotNull(), a => a.Phone == input.Phone)
-                .Or(input.Name.NotNull(), a => a.Name == input.Name);
+            //where = where.Or(input.Phone.NotNull(), a => a.Phone == input.Phone);
+                //.And(input.Name.NotNull(), a => a.Name == input.Name);
 
             var existsUser = await _platformUserRepository.Select.Where(where).DisableGlobalFilter().Where(a => a.TenantId == org.TenantId)
                 .FirstAsync(a => new { a.Name, a.Phone, a.TenantId });
@@ -236,7 +268,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
 
                 if (input.Phone.NotNull() && existsUser.Phone == input.Phone)
                 {
-                    throw ResultOutput.Exception($"手机号已存在");
+                    throw ResultOutput.Exception($"手机号已注册");
                 }
 
                 //if (input.Name.NotNull() && existsUser.Name == input.Name)
@@ -323,7 +355,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         /// </summary>
         /// <param name="phone"></param>
         /// <returns></returns>
-        [HttpGet]
+        [HttpPost]
         [AllowAnonymous]
         [NoOprationLog]
         public string SendCode(string phone)

+ 21 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Dto/RegisterInput.cs

@@ -8,13 +8,34 @@ namespace ZhonTai.Admin.Services.DiTuiAPI.Dto
 {
     public class RegisterInput
     {
+        /// <summary>
+        /// 用户名
+        /// </summary>
         public string Name { get; set; }
 
+        /// <summary>
+        /// 手机号
+        /// </summary>
         public string Phone { get; set; }
 
+        /// <summary>
+        /// 短信验证码
+        /// </summary>
+        public string VCode { get; set; }
+
+        /// <summary>
+        /// 密码
+        /// </summary>
         public string Password { get; set; }
+
+        /// <summary>
+        /// 检查密码
+        /// </summary>
         public string PasswordCheck { get; set; }
 
+        /// <summary>
+        /// 邀请码
+        /// </summary>
         public string InvitCode { get; set; }
     }
 }

+ 30 - 0
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -6323,6 +6323,36 @@
             佣金
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.RegisterInput.Name">
+            <summary>
+            用户名
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.RegisterInput.Phone">
+            <summary>
+            手机号
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.RegisterInput.VCode">
+            <summary>
+            短信验证码
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.RegisterInput.Password">
+            <summary>
+            密码
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.RegisterInput.PasswordCheck">
+            <summary>
+            检查密码
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.RegisterInput.InvitCode">
+            <summary>
+            邀请码
+            </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.UserInfoOutput.Avatar">
             <summary>
             头像