优化token过期提示为警告
This commit is contained in:
+4
-3
@@ -8,6 +8,7 @@ import xtools.app.sys.auth.model.dto.LoginUserDto;
|
|||||||
import xtools.app.sys.auth.model.dto.TokenDto;
|
import xtools.app.sys.auth.model.dto.TokenDto;
|
||||||
import xtools.boot.api.constant.BootCommonConstant;
|
import xtools.boot.api.constant.BootCommonConstant;
|
||||||
import xtools.boot.api.exection.BizError;
|
import xtools.boot.api.exection.BizError;
|
||||||
|
import xtools.boot.api.exection.BizWarning;
|
||||||
import xtools.boot.api.exection.UnauthorizedError;
|
import xtools.boot.api.exection.UnauthorizedError;
|
||||||
import xtools.boot.cache.redis.base.RedisService;
|
import xtools.boot.cache.redis.base.RedisService;
|
||||||
import xtools.boot.cache.redis.utils.RedisUtils;
|
import xtools.boot.cache.redis.utils.RedisUtils;
|
||||||
@@ -280,16 +281,16 @@ public class AuthUtils {
|
|||||||
JSONObject jwtToken = AuthJwtUtils.verifyToken(refreshToken);
|
JSONObject jwtToken = AuthJwtUtils.verifyToken(refreshToken);
|
||||||
refreshToken = jwtToken.getString(AuthUtils.JWT_TOKEN);
|
refreshToken = jwtToken.getString(AuthUtils.JWT_TOKEN);
|
||||||
if (StringUtils.isBlank(refreshToken)) {
|
if (StringUtils.isBlank(refreshToken)) {
|
||||||
throw new BizError("token已过期,请重新登录");
|
throw new BizWarning("token已过期,请重新登录");
|
||||||
}
|
}
|
||||||
RedisService redis = RedisUtils.get();
|
RedisService redis = RedisUtils.get();
|
||||||
String accessToken = redis.get(getCacheKey(REFRESH_TOKEN, refreshToken), String.class);
|
String accessToken = redis.get(getCacheKey(REFRESH_TOKEN, refreshToken), String.class);
|
||||||
if (StringUtils.isBlank(accessToken)) {
|
if (StringUtils.isBlank(accessToken)) {
|
||||||
throw new BizError("token已过期,请重新登录");
|
throw new BizWarning("token已过期,请重新登录");
|
||||||
}
|
}
|
||||||
LoginUserDto loginUser = getFromCache(accessToken, false);
|
LoginUserDto loginUser = getFromCache(accessToken, false);
|
||||||
if (loginUser == null) {
|
if (loginUser == null) {
|
||||||
throw new BizError("token已过期,请重新登录");
|
throw new BizWarning("token已过期,请重新登录");
|
||||||
}
|
}
|
||||||
if (!checkJwtToken(jwtToken, uid, loginUser.getId())) {
|
if (!checkJwtToken(jwtToken, uid, loginUser.getId())) {
|
||||||
remove(loginUser.getId());
|
remove(loginUser.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user