mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-10 16:12:50 +00:00
fix tenant ex
This commit is contained in:
parent
50c33b5184
commit
264fbbeb5f
@ -53,6 +53,17 @@ export class TenantSubscriber implements EntitySubscriberInterface<any> {
|
||||
urls: string[];
|
||||
};
|
||||
|
||||
// 系统接口不过滤
|
||||
ignoreUrls = [
|
||||
'/admin/base/open/login',
|
||||
'/admin/base/comm/person',
|
||||
'/admin/base/comm/permmenu',
|
||||
'/admin/dict/info/data',
|
||||
];
|
||||
|
||||
// 不进行租户过滤的用户
|
||||
ignoreUsername = ['admin'];
|
||||
|
||||
@Inject()
|
||||
utils: Utils;
|
||||
|
||||
@ -96,7 +107,14 @@ export class TenantSubscriber implements EntitySubscriberInterface<any> {
|
||||
ctx = this.getCtx();
|
||||
if (!ctx || !this.checkHandler()) return undefined;
|
||||
url = ctx?.url;
|
||||
|
||||
// 忽略用户
|
||||
if (this.ignoreUsername.includes(ctx?.admin?.username)) {
|
||||
return undefined;
|
||||
}
|
||||
// 忽略系统接口
|
||||
if (this.ignoreUrls.some(pattern => this.utils.matchUrl(pattern, url))) {
|
||||
return undefined;
|
||||
}
|
||||
if (_.startsWith(url, '/admin/')) {
|
||||
tenantId = ctx?.admin?.tenantId;
|
||||
} else if (_.startsWith(url, '/app/')) {
|
||||
@ -130,7 +148,7 @@ export class TenantSubscriber implements EntitySubscriberInterface<any> {
|
||||
if (!this.tenant.enable) return;
|
||||
const tenantId = await this.getTenantId();
|
||||
if (tenantId) {
|
||||
queryBuilder.values({ tenantId });
|
||||
queryBuilder.setParameter('tenantId', tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,6 @@ export class BaseAuthorityMiddleware
|
||||
if (_.startsWith(url, adminUrl)) {
|
||||
try {
|
||||
ctx.admin = jwt.verify(token, this.jwtConfig.jwt.secret);
|
||||
ctx.admin.tenantId = 1;
|
||||
if (ctx.admin.isRefresh) {
|
||||
ctx.status = 401;
|
||||
throw new CoolCommException('登录失效~', ctx.status);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user