修复satoken
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package com.corewing.app.config;
|
package com.corewing.app.config;
|
||||||
|
|
||||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||||
import cn.dev33.satoken.router.SaRouter;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
@@ -19,19 +18,16 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
|||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
// 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验。
|
// 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验。
|
||||||
registry.addInterceptor(new SaInterceptor(handle -> {
|
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||||
// 指定一条 match 规则
|
|
||||||
SaRouter
|
|
||||||
// 拦截所有路由
|
// 拦截所有路由
|
||||||
.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 监控
|
// 排除 Druid 监控
|
||||||
.notMatch("/druid/**")
|
.excludePathPatterns("/druid/**")
|
||||||
// 执行认证校验
|
// 排除错误页面
|
||||||
.check(r -> StpUtil.checkLogin());
|
.excludePathPatterns("/error", "/error/**");
|
||||||
})).addPathPatterns("/**");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user