修复satoken
This commit is contained in:
@@ -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
|
||||
// 拦截所有路由
|
||||
.match("/**")
|
||||
// 排除登录、注册、发送验证码接口
|
||||
.notMatch("/user/login", "/user/register", "/user/sendCode")
|
||||
// 排除静态资源
|
||||
.notMatch("/", "/index.html", "/*.html", "/*.css", "/*.js", "/*.ico", "/static/**")
|
||||
// 排除 Druid 监控
|
||||
.notMatch("/druid/**")
|
||||
// 执行认证校验
|
||||
.check(r -> StpUtil.checkLogin());
|
||||
})).addPathPatterns("/**");
|
||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||
// 拦截所有路由
|
||||
.addPathPatterns("/**")
|
||||
// 排除登录、注册、发送验证码接口
|
||||
.excludePathPatterns("/user/login", "/user/register", "/user/sendCode")
|
||||
// 排除静态资源
|
||||
.excludePathPatterns("/", "/index.html", "/*.html", "/*.css", "/*.js", "/*.ico", "/static/**")
|
||||
// 排除 Druid 监控
|
||||
.excludePathPatterns("/druid/**")
|
||||
// 排除错误页面
|
||||
.excludePathPatterns("/error", "/error/**");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user