NewLife/NewLife.Cube

修复:未启用多租户时跳过租户关系填充

在 FillTenant 方法中增加多租户开关判断,未开启多租户功能时直接返回,避免误创建租户关系导致系统进入租户模式,提升兼容性和健壮性。
大石头 authored at 2026-06-04 00:36:46
59b0c95
Tree
1 Parent(s) 7cc49f0
Summary: 1 changed files with 3 additions and 0 deletions.
Modified +3 -0
Modified +3 -0
diff --git a/NewLife.Cube/Services/Sso/UserBindingService.cs b/NewLife.Cube/Services/Sso/UserBindingService.cs
index bbfd7ca..111fae4 100644
--- a/NewLife.Cube/Services/Sso/UserBindingService.cs
+++ b/NewLife.Cube/Services/Sso/UserBindingService.cs
@@ -461,6 +461,9 @@ public class UserBindingService : IUserBindingService
     /// <summary>填充租户信息</summary>
     protected virtual void FillTenant(OAuthClient client, User user, IManageUser manageUser)
     {
+        // 未开启多租户时跳过,避免自动创建租户关系导致 ChooseTenant 切入租户模式
+        if (!CubeSetting.Current.EnableTenant) return;
+
         var log = LogProvider.Provider;
 
         if (!client.TenantCode.IsNullOrEmpty() && !client.TenantName.IsNullOrEmpty())