Merge pull request #470 from dataease/pr@dev@fix_token过期

fix: token过期点击确定没有跳转到登录
This commit is contained in:
fit2cloud-chenyw 2021-08-02 18:28:22 +08:00 committed by GitHub
commit ee234898cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View File

@ -49,6 +49,9 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
String authorization = httpServletRequest.getHeader("Authorization");
if (StringUtils.startsWith(authorization, "Basic")) {
return false;
}
// 当没有出现登录超时 且需要刷新token 则执行刷新token
if (JWTUtils.loginExpire(authorization)){
throw new AuthenticationException(expireMessage);

View File

@ -12,6 +12,7 @@ import io.dataease.auth.util.JWTUtils;
import io.dataease.auth.util.RsaUtil;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.CodingUtil;
import io.dataease.commons.utils.LogUtil;
import io.dataease.commons.utils.ServletUtils;
import io.dataease.exception.DataEaseException;
@ -84,8 +85,17 @@ public class AuthServer implements AuthApi {
@Override
public String logout() {
String token = ServletUtils.getToken();
Long userId = JWTUtils.tokenInfoByToken(token).getUserId();
authUserService.clearCache(userId);
if (StringUtils.isEmpty(token) || StringUtils.equals("null", token) || StringUtils.equals("undefined", token)) {
return "success";
}
try{
Long userId = JWTUtils.tokenInfoByToken(token).getUserId();
authUserService.clearCache(userId);
}catch (Exception e) {
LogUtil.error(e);
return "fail";
}
return "success";
}

View File

@ -64,6 +64,7 @@ import { query, updateStatus } from '@/api/system/msg'
import { getTypeName, loadMsgTypes } from '@/utils/webMsg'
import { mapGetters } from 'vuex'
import bus from '@/utils/bus'
import { getToken } from '@/utils/auth'
export default {
data() {
return {
@ -172,6 +173,11 @@ export default {
query(currentPage, pageSize, param).then(response => {
this.data = response.data.listObject
this.paginationConfig.total = response.data.itemCount
}).catch(() => {
const token = getToken()
if (!token || token === 'null' || token === 'undefined') {
this.timer && clearInterval(this.timer)
}
})
},
getTypeName(value) {