Browse Source

添加租户支持添加自定义密码

zhontai 1 year ago
parent
commit
080c2984a0

+ 5 - 0
src/platform/ZhonTai.Admin/Services/Tenant/Dto/TenantAddInput.cs

@@ -41,6 +41,11 @@ public class TenantAddInput
     [Required(ErrorMessage = "请输入账号")]
     public string UserName { get; set; }
 
+    /// <summary>
+    /// 密码
+    /// </summary>
+    public string Password { get; set; }
+
     /// <summary>
     /// 手机号码
     /// </summary>

+ 6 - 2
src/platform/ZhonTai.Admin/Services/Tenant/TenantService.cs

@@ -201,6 +201,10 @@ public class TenantService : BaseService, ITenantService, IDynamicApi
             await _orgRepository.InsertAsync(org);
 
             //添加用户
+            if (input.Password.IsNull())
+            {
+                input.Password = _appConfig.DefaultPassword;
+            }
             var user = new UserEntity
             {
                 TenantId = tenantId,
@@ -214,12 +218,12 @@ public class TenantService : BaseService, ITenantService, IDynamicApi
             };
             if (_appConfig.PasswordHasher)
             {
-                user.Password = _passwordHasher.HashPassword(user, _appConfig.DefaultPassword);
+                user.Password = _passwordHasher.HashPassword(user, input.Password);
                 user.PasswordEncryptType = PasswordEncryptType.PasswordHasher;
             }
             else
             {
-                user.Password = MD5Encrypt.Encrypt32(_appConfig.DefaultPassword);
+                user.Password = MD5Encrypt.Encrypt32(input.Password);
                 user.PasswordEncryptType = PasswordEncryptType.MD5Encrypt32;
             }
             await _userRepository.InsertAsync(user);

+ 3 - 0
src/platform/ZhonTai.Admin/Services/User/Dto/UserAddInput.cs

@@ -5,6 +5,9 @@
 /// </summary>
 public class UserAddInput: UserFormInput
 {
+    /// <summary>
+    /// 密码
+    /// </summary>
     public virtual string Password { get; set; }
 
     /// <summary>

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

@@ -6986,6 +6986,11 @@
             账号
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Services.Tenant.Dto.TenantAddInput.Password">
+            <summary>
+            密码
+            </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Services.Tenant.Dto.TenantAddInput.Phone">
             <summary>
             手机号码
@@ -7197,6 +7202,11 @@
             添加
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Services.User.Dto.UserAddInput.Password">
+            <summary>
+            密码
+            </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Services.User.Dto.UserAddInput.Enabled">
             <summary>
             启用