fix(X-Pack): CAS登录session过期后系统未退出
This commit is contained in:
parent
ecc61aca44
commit
7936afbf0d
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user