mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2024-11-01 14:10:29 +08:00
修复sso单点登录
This commit is contained in:
parent
2a1028211e
commit
33335c9523
@ -43,10 +43,22 @@ export class BaseAuthorityMiddleware
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ctx.admin) {
|
if (ctx.admin) {
|
||||||
|
const rToken = await this.cacheManager.get(
|
||||||
|
`admin:token:${ctx.admin.userId}`
|
||||||
|
);
|
||||||
// 超管拥有所有权限
|
// 超管拥有所有权限
|
||||||
if (ctx.admin.username == 'admin' && !ctx.admin.isRefresh) {
|
if (ctx.admin.username == 'admin' && !ctx.admin.isRefresh) {
|
||||||
await next();
|
if (rToken !== token && this.jwtConfig.jwt.sso) {
|
||||||
return;
|
ctx.status = 401;
|
||||||
|
ctx.body = {
|
||||||
|
code: RESCODE.COMMFAIL,
|
||||||
|
message: '登录失效~',
|
||||||
|
};
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
await next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 要登录每个人都有权限的接口
|
// 要登录每个人都有权限的接口
|
||||||
if (new RegExp(`^${adminUrl}?.*/comm/`).test(url)) {
|
if (new RegExp(`^${adminUrl}?.*/comm/`).test(url)) {
|
||||||
@ -74,9 +86,7 @@ export class BaseAuthorityMiddleware
|
|||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rToken = await this.cacheManager.get(
|
|
||||||
`admin:token:${ctx.admin.userId}`
|
|
||||||
);
|
|
||||||
if (!rToken) {
|
if (!rToken) {
|
||||||
ctx.status = 401;
|
ctx.status = 401;
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
@ -85,7 +95,7 @@ export class BaseAuthorityMiddleware
|
|||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rToken !== token && this.jwtConfig.sso) {
|
if (rToken !== token && this.jwtConfig.jwt.sso) {
|
||||||
statusCode = 401;
|
statusCode = 401;
|
||||||
} else {
|
} else {
|
||||||
let perms: string[] = await this.cacheManager.get(
|
let perms: string[] = await this.cacheManager.get(
|
||||||
|
Loading…
Reference in New Issue
Block a user