Переглянути джерело

用户登录接口判断用户租户

lifa 1 рік тому
батько
коміт
a3dfcd7bd1

+ 11 - 1
src/platform/ZhonTai.Admin/Services/DiTuiAPI/DiTuiAPIService.cs

@@ -60,6 +60,16 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         [NoOprationLog]
         public async Task<dynamic> LoginAsync(LoginInput input)
         {
+            var platform = _httpContextAccessor.HttpContext.Request.Headers["platform"];
+
+            if (string.IsNullOrEmpty(platform))
+            {
+                throw ResultOutput.Exception($"平台编码不可为空");
+            }
+            var org = await _orgRepository.Select.Where(a => a.Code == platform).DisableGlobalFilter()
+                .FirstAsync(a => new { a.Name, a.TenantId });
+
+
             using (_platformUserRepository.DataFilter.DisableAll())
             {
                 var sw = new Stopwatch();
@@ -107,7 +117,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
                 #endregion
 
                 #region 登录
-                var user = await _platformUserRepository.Select.Where(a => a.Phone == input.mobile).ToOneAsync();
+                var user = await _platformUserRepository.Select.Where(a => a.Phone == input.mobile && a.TenantId == org.TenantId).ToOneAsync();
                 var valid = user?.Id > 0;
                 if (valid)
                 {