|
|
@@ -2,10 +2,12 @@ package com.haha.miniapp.config;
|
|
|
|
|
|
import cn.dev33.satoken.interceptor.SaInterceptor;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Configuration
|
|
|
public class SaTokenConfig implements WebMvcConfigurer {
|
|
|
|
|
|
@@ -13,6 +15,14 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
// 注册Sa-Token拦截器,拦截所有路径
|
|
|
registry.addInterceptor(new SaInterceptor(handle -> {
|
|
|
+ // 记录token信息(用于调试)
|
|
|
+ String tokenValue = StpUtil.getTokenValue();
|
|
|
+ if (tokenValue != null && !tokenValue.isEmpty()) {
|
|
|
+ log.debug("当前请求token: {}, 是否登录: {}", tokenValue, StpUtil.isLogin());
|
|
|
+ } else {
|
|
|
+ log.debug("当前请求未携带token");
|
|
|
+ }
|
|
|
+
|
|
|
// 登录认证:除了指定的接口,其他都需要登录
|
|
|
StpUtil.checkLogin();
|
|
|
}))
|