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