修复satoken
Some checks failed
CI Build and Test / build (push) Has been cancelled
Deploy to Server / build-and-deploy (push) Has been cancelled

This commit is contained in:
2025-10-20 17:11:51 +08:00
parent 2c8b0a7b2b
commit cf3a17073d

View File

@@ -1,7 +1,6 @@
package com.corewing.app.config;
import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
@@ -19,19 +18,16 @@ public class SaTokenConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验。
registry.addInterceptor(new SaInterceptor(handle -> {
// 指定一条 match 规则
SaRouter
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
// 拦截所有路由
.match("/**")
.addPathPatterns("/**")
// 排除登录、注册、发送验证码接口
.notMatch("/user/login", "/user/register", "/user/sendCode")
.excludePathPatterns("/user/login", "/user/register", "/user/sendCode")
// 排除静态资源
.notMatch("/", "/index.html", "/*.html", "/*.css", "/*.js", "/*.ico", "/static/**")
.excludePathPatterns("/", "/index.html", "/*.html", "/*.css", "/*.js", "/*.ico", "/static/**")
// 排除 Druid 监控
.notMatch("/druid/**")
// 执行认证校验
.check(r -> StpUtil.checkLogin());
})).addPathPatterns("/**");
.excludePathPatterns("/druid/**")
// 排除错误页面
.excludePathPatterns("/error", "/error/**");
}
}