diff --git a/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs b/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs index a3a9f224..540dd5ed 100644 --- a/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs @@ -59,7 +59,13 @@ public class SysAuthService : IDynamicApiController, ITransient if (passwordErrorTimes > passwordMaxErrorTimes) throw Oops.Oh(ErrorCodeEnum.D1027); // 判断是否开启验证码并校验 - var tenant = _sysCacheService.Get>(CacheConst.KeyTenant)?.WhereIF(input.TenantId > 0, u => u.Id == input.TenantId).FirstOrDefault(); + var tenant = _sysCacheService.Get>(CacheConst.KeyTenant)?.WhereIF(input.TenantId > 0, u => u.Id == input.TenantId).FirstOrDefault(); + // 缓存被清服务不重启这里tenant会为空,出错 + if (tenant==null && input.TenantId==0) + { + await App.GetRequiredService().CacheTenant(); + tenant = _sysCacheService.Get>(CacheConst.KeyTenant)?.WhereIF(input.TenantId > 0, u => u.Id == input.TenantId).FirstOrDefault(); + } if (tenant.Captcha == true && !_captcha.Validate(input.CodeId.ToString(), input.Code)) throw Oops.Oh(ErrorCodeEnum.D0008); diff --git a/Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs b/Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs index dfa6d9fd..f5b76f58 100644 --- a/Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs @@ -393,7 +393,9 @@ public class SysRoleService : IDynamicApiController, ITransient var roleApiList = await _sysRoleApiService.GetRoleApiList(roleIdList); apiList[1].AddRange(roleApiList); } - _sysCacheService.Set(CacheConst.KeyUserApi + userId, apiList, TimeSpan.FromDays(7)); // 缓存7天 + _sysCacheService.Set(CacheConst.KeyUserApi + userId, apiList, TimeSpan.FromDays(7)); // 缓存7天 + foreach (var lst in apiList) + lst.Sort(); return apiList; }