From 4cd7c073444cbf529d71854bd3c10005dd71b9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Fri, 1 Apr 2022 15:43:51 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20sa-token=20?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=8B=A6=E6=88=AA=E5=99=A8=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E6=B3=A8=E9=87=8A=20=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E8=AF=AF=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/framework/config/SaTokenConfig.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java index 54f373be..671400f6 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java @@ -5,7 +5,7 @@ import cn.dev33.satoken.interceptor.SaRouteInterceptor; import cn.dev33.satoken.jwt.StpLogicJwtForStyle; import cn.dev33.satoken.router.SaRouter; import cn.dev33.satoken.stp.StpLogic; -import cn.hutool.core.util.ObjectUtil; +import cn.dev33.satoken.stp.StpUtil; import com.ruoyi.common.helper.LoginHelper; import com.ruoyi.framework.config.properties.SecurityProperties; import lombok.RequiredArgsConstructor; @@ -43,15 +43,17 @@ public class SaTokenConfig implements WebMvcConfigurer { .match("/**") // 排除下不需要拦截的 .notMatch(securityProperties.getExcludes()) + // 对未排除的路径进行检查 .check(() -> { - Long userId = LoginHelper.getUserId(); - if (ObjectUtil.isNotNull(userId)) { - // 有效率影响 用于临时测试 - // if (log.isDebugEnabled()) { - // log.debug("剩余有效时间: {}", StpUtil.getTokenTimeout()); - // log.debug("临时有效时间: {}", StpUtil.getTokenActivityTimeout()); - // } - } + // 检查是否登录 是否有token + StpUtil.checkLogin(); + + // 有效率影响 用于临时测试 + // if (log.isDebugEnabled()) { + // log.debug("剩余有效时间: {}", StpUtil.getTokenTimeout()); + // log.debug("临时有效时间: {}", StpUtil.getTokenActivityTimeout()); + // } + }); }) { @SuppressWarnings("all")