Commit 9b687ff6c9eb945f29c2728704841e9443a01108

Authored by YunaiV
1 parent 6471c8d5

:bug: 修复忽略租户的 URL,未带租户会报错的问题

yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java
... ... @@ -75,7 +75,7 @@ public class TenantSecurityWebFilter extends ApiRequestFilter {
75 75 }
76 76 }
77 77  
78   - //检查是否是忽略的 URL, 如果是则允许访问
  78 + // 如果非允许忽略租户的 URL,则校验租户是否合法
79 79 if (!isIgnoreUrl(request)) {
80 80 // 2. 如果请求未带租户的编号,不允许访问。
81 81 if (tenantId == null) {
... ... @@ -92,6 +92,10 @@ public class TenantSecurityWebFilter extends ApiRequestFilter {
92 92 ServletUtils.writeJSON(response, result);
93 93 return;
94 94 }
  95 + } else { // 如果是允许忽略租户的 URL,若未传递租户编号,则默认忽略租户编号,避免报错
  96 + if (tenantId == null) {
  97 + TenantContextHolder.setIgnore(true);
  98 + }
95 99 }
96 100  
97 101 // 继续过滤
... ...
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.http
  1 +### 获取租户编号 /admin-api/system/get-id-by-name
  2 +GET {{baseUrl}}/system/tenant/get-id-by-name?name=芋道源码
  3 +
1 4 ### 创建租户 /admin-api/system/tenant/create
2 5 POST {{baseUrl}}/system/tenant/create
3 6 Content-Type: application/json
... ...