优化token过期提示为警告

This commit is contained in:
2026-08-12 10:47:23 +08:00
parent aabc5c5c6b
commit 1fe185109b
@@ -8,6 +8,7 @@ import xtools.app.sys.auth.model.dto.LoginUserDto;
import xtools.app.sys.auth.model.dto.TokenDto;
import xtools.boot.api.constant.BootCommonConstant;
import xtools.boot.api.exection.BizError;
import xtools.boot.api.exection.BizWarning;
import xtools.boot.api.exection.UnauthorizedError;
import xtools.boot.cache.redis.base.RedisService;
import xtools.boot.cache.redis.utils.RedisUtils;
@@ -280,16 +281,16 @@ public class AuthUtils {
JSONObject jwtToken = AuthJwtUtils.verifyToken(refreshToken);
refreshToken = jwtToken.getString(AuthUtils.JWT_TOKEN);
if (StringUtils.isBlank(refreshToken)) {
throw new BizError("token已过期,请重新登录");
throw new BizWarning("token已过期,请重新登录");
}
RedisService redis = RedisUtils.get();
String accessToken = redis.get(getCacheKey(REFRESH_TOKEN, refreshToken), String.class);
if (StringUtils.isBlank(accessToken)) {
throw new BizError("token已过期,请重新登录");
throw new BizWarning("token已过期,请重新登录");
}
LoginUserDto loginUser = getFromCache(accessToken, false);
if (loginUser == null) {
throw new BizError("token已过期,请重新登录");
throw new BizWarning("token已过期,请重新登录");
}
if (!checkJwtToken(jwtToken, uid, loginUser.getId())) {
remove(loginUser.getId());