Commit dff0ff9b authored by zhouxudong's avatar zhouxudong

token过期处理

parent 74a1545a
...@@ -24,13 +24,7 @@ public class CurrentUserInterceptor implements AsyncHandlerInterceptor { ...@@ -24,13 +24,7 @@ public class CurrentUserInterceptor implements AsyncHandlerInterceptor {
throw new AuthException("未授权,请重新登录"); throw new AuthException("未授权,请重新登录");
} }
String token = authToken.substring("Bearer".length() + 1).trim(); String token = authToken.substring("Bearer".length() + 1).trim();
JwtInfo jwtUser; JwtInfo jwtUser = JwtTokenUtil.getJwtUser(token);
try{
jwtUser = JwtTokenUtil.getJwtUser(token);
}catch (Exception e){
throw new AuthException("未授权,请重新登录");
}
// 根据token信息,生成当前登录用户信息的设置,存放容器threadlocal // 根据token信息,生成当前登录用户信息的设置,存放容器threadlocal
BaseContextHandler.setCurrentUserInfo(jwtUser); BaseContextHandler.setCurrentUserInfo(jwtUser);
......
...@@ -101,9 +101,7 @@ public class JwtTokenUtil { ...@@ -101,9 +101,7 @@ public class JwtTokenUtil {
Long nowTime = System.currentTimeMillis(); Long nowTime = System.currentTimeMillis();
log.debug("nowTime : " + nowTime); log.debug("nowTime : " + nowTime);
if (nowTime > expireTime) { if (nowTime > expireTime) {
resultMap.clear(); throw new AuthException("token过期");
flag = false;
resultMap.put(TokenConstants.RESULT, TokenConstants.TOKEN_RESULT.TOKEN_EXPIRED);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment