fix(X-Pack): CAS登录session过期后系统未退出

This commit is contained in:
fit2cloud-chenyw 2024-09-20 16:08:07 +08:00
parent ecc61aca44
commit 7936afbf0d
2 changed files with 15 additions and 1 deletions

View File

@ -86,7 +86,7 @@ public class CasStrategy implements UrlPatternMatcherStrategy {
try {
DecodedJWT jwt = JWT.decode(token);
Claim forShot = jwt.getClaim("forShot");
return ObjectUtils.isNotEmpty(forShot) && forShot.asBoolean();
return ObjectUtils.isNotEmpty(forShot) && !forShot.isNull() && forShot.asBoolean();
} catch (Exception e) {
LogUtil.error(e.getMessage());
return false;

View File

@ -114,6 +114,7 @@ service.setTimeOut = time => {
// 请根据实际需求修改
service.interceptors.response.use(response => {
checkCasRedirect(response)
response.config.loading && tryHideLoading(store.getters.currentPath)
checkAuth(response)
Vue.prototype.$currentHttpRequestList.delete(response.config.url)
@ -191,4 +192,17 @@ const checkAuth = response => {
store.dispatch('user/setLinkToken', linkToken)
}
}
const checkCasRedirect = (response) => {
if (!response || !response.data) {
return
}
const resData = response.data
const routine = resData.hasOwnProperty('success')
const redirectUrl = response?.request?.responseURL
if (resData && !routine && resData.startsWith('<!') && redirectUrl?.includes('cas/login')) {
store.dispatch('user/logout').finally(() => {
location.reload()
})
}
}
export default service