From 5344255a733fc8865d22304d6e6e9fefff23a565 Mon Sep 17 00:00:00 2001 From: chenjg <17688741996@163.com> Date: Mon, 29 Jul 2024 14:27:16 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E8=AE=A4=E8=AF=81=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E7=B3=BB=E7=BB=9F=E7=94=A8=E6=88=B7=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/filter/JsonWebTokenValidFilter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/neatlogic/framework/filter/JsonWebTokenValidFilter.java b/src/main/java/neatlogic/framework/filter/JsonWebTokenValidFilter.java index 967cb6f92..17e8841b9 100644 --- a/src/main/java/neatlogic/framework/filter/JsonWebTokenValidFilter.java +++ b/src/main/java/neatlogic/framework/filter/JsonWebTokenValidFilter.java @@ -31,6 +31,7 @@ import neatlogic.framework.dto.JwtVo; import neatlogic.framework.dto.UserSessionVo; import neatlogic.framework.dto.UserVo; import neatlogic.framework.exception.core.ApiRuntimeException; +import neatlogic.framework.exception.user.UserNotFoundException; import neatlogic.framework.filter.core.ILoginAuthHandler; import neatlogic.framework.filter.core.LoginAuthFactory; import neatlogic.framework.login.core.ILoginPostProcessor; @@ -159,6 +160,15 @@ public class JsonWebTokenValidFilter extends OncePerRequestFilter { logger.error(ex.getMessage(), ex); returnErrorResponseJson(ResponseCode.API_RUNTIME, response, false, ex.getMessage()); } + } catch (UserNotFoundException ex) { + logger.error(ex.getMessage(), ex); + try { + // 不返回跳转地址,直接跳转到显示错误信息页面 + returnErrorResponseJson(ResponseCode.AUTH_FAILED, response, null, ex.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ApiRuntimeException(e); + } } catch (Exception ex) { logger.error(ex.getMessage(), ex); try { @@ -249,7 +259,7 @@ public class JsonWebTokenValidFilter extends OncePerRequestFilter { if (now.getTime() < expireTime) { String authInfo = userSessionContentMapper.getUserSessionContentByHash(userSessionVo.getAuthInfoHash()); userSessionVo.setAuthInfoStr(authInfo); - userSessionMapper.updateUserSession(jwt.getTokenHash()); + userSessionMapper.updateUserSessionTimeByTokenHash(jwt.getTokenHash()); AuthenticationInfoVo authenticationInfo = userSessionVo.getAuthInfo(); UserSessionCache.addItem(jwt.getTokenHash(), JSON.toJSONString(authenticationInfo)); UserContext.init(userVo, authenticationInfo, timezone, request, response); -- Gitee