|
|
|
@ -15,6 +15,9 @@ import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic';
@@ -15,6 +15,9 @@ import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic';
|
|
|
|
|
import { setObjToUrlParams } from '/@/utils'; |
|
|
|
|
import { AesEncryption } from '/@/utils/cipher'; |
|
|
|
|
import { cacheCipher } from '/@/settings/encryptionSetting'; |
|
|
|
|
import axios from 'axios'; |
|
|
|
|
import { useGlobSetting } from '/@/hooks/setting'; |
|
|
|
|
import { Api } from '/@/api/platform/core/controller/user'; |
|
|
|
|
|
|
|
|
|
type BasicPageEnum = PageEnum | SsoLoginPageEnum; |
|
|
|
|
const LOGIN_PATH = PageEnum.BASE_LOGIN; |
|
|
|
@ -23,6 +26,7 @@ const ssoPathList: SsoLoginPageEnum[] = Object.values(SsoLoginPageEnum);
@@ -23,6 +26,7 @@ const ssoPathList: SsoLoginPageEnum[] = Object.values(SsoLoginPageEnum);
|
|
|
|
|
/** 设置路由白名单 */ |
|
|
|
|
const whitePathList: BasicPageEnum[] = [ LOGIN_PATH, ...ssoPathList ]; |
|
|
|
|
const encryption = new AesEncryption({ key: cacheCipher.key, iv: cacheCipher.iv }); |
|
|
|
|
const globSetting = useGlobSetting(); |
|
|
|
|
|
|
|
|
|
export function createPermissionGuard(router: Router) { |
|
|
|
|
const userStore = useUserStoreWithOut(); |
|
|
|
@ -32,9 +36,13 @@ export function createPermissionGuard(router: Router) {
@@ -32,9 +36,13 @@ export function createPermissionGuard(router: Router) {
|
|
|
|
|
const token = userStore.getAccessToken; |
|
|
|
|
// sso重定向转发token进行登陆
|
|
|
|
|
if(ssoPathList.includes(to.path as SsoLoginPageEnum) && token) { |
|
|
|
|
try { |
|
|
|
|
// 校验token是否过期
|
|
|
|
|
await axios.get(`${globSetting.apiUrl}${globSetting.urlPrefix}${Api.checkToken}`, {params: {token}}); |
|
|
|
|
return window.location.replace(to.query?.redirect ? setObjToUrlParams(to.query?.redirect as string, { |
|
|
|
|
ticket: encryption.encryptByAES(token) |
|
|
|
|
}) : '/'); |
|
|
|
|
} catch (e) {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|