防止错误token导致的解析异常

This commit is contained in:
RuoYi 2021-07-29 17:32:55 +08:00
parent 6b5dd4d2be
commit f6bc28000e
2 changed files with 13 additions and 7 deletions

View File

@ -60,12 +60,18 @@ public class TokenService
String token = getToken(request); String token = getToken(request);
if (StringUtils.isNotEmpty(token)) if (StringUtils.isNotEmpty(token))
{ {
Claims claims = parseToken(token); try
// 解析对应的权限以及用户信息 {
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); Claims claims = parseToken(token);
String userKey = getTokenKey(uuid); // 解析对应的权限以及用户信息
LoginUser user = redisCache.getCacheObject(userKey); String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
return user; String userKey = getTokenKey(uuid);
LoginUser user = redisCache.getCacheObject(userKey);
return user;
}
catch (Exception e)
{
}
} }
return null; return null;
} }

View File

@ -64,7 +64,7 @@ service.interceptors.response.use(res => {
location.href = '/index'; location.href = '/index';
}) })
}).catch(() => {}); }).catch(() => {});
return Promise.reject('error') return Promise.reject()
} else if (code === 500) { } else if (code === 500) {
Message({ Message({
message: msg, message: msg,