|
@@ -20,17 +20,30 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|
// 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验。
|
|
// 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验。
|
|
ArrayList<String> list = new ArrayList<>();
|
|
ArrayList<String> list = new ArrayList<>();
|
|
list.add("/samplescan/user/login");
|
|
list.add("/samplescan/user/login");
|
|
- list.add("/samplescan/api/getimg/**");
|
|
|
|
|
|
+ list.add("/samplescan/api/upload/**");
|
|
|
|
+ list.add("/favicon.ico");
|
|
|
|
+ list.add("/error");
|
|
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
|
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
|
.addPathPatterns("/**")
|
|
.addPathPatterns("/**")
|
|
.excludePathPatterns(list);
|
|
.excludePathPatterns(list);
|
|
-
|
|
|
|
-// registry.addInterceptor(new SaInterceptor(handler -> {
|
|
|
|
-// // 指定一条 match 规则
|
|
|
|
-// SaRouter.match("/**") // 拦截的 path 列表,可以写多个 */
|
|
|
|
-// .notMatch("/samplescan/user/login")
|
|
|
|
-// .notMatch("/samplescan/api/getimg/**")
|
|
|
|
-// .check(r -> StpUtil.checkLogin());
|
|
|
|
-// })).addPathPatterns("/**");
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// @Override
|
|
|
|
+// public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
+// ArrayList<String> list = new ArrayList<>();
|
|
|
|
+// list.add("/samplescan/user/login");
|
|
|
|
+// list.add("/samplescan/api/upload/**");
|
|
|
|
+// list.add("/favicon.ico");
|
|
|
|
+// list.add("/error");
|
|
|
|
+// registry.addInterceptor(new SaInterceptor(handle -> {
|
|
|
|
+// try {
|
|
|
|
+// System.out.println("-------- 前端访问path:" + SaHolder.getRequest().getRequestPath());
|
|
|
|
+// StpUtil.checkLogin();
|
|
|
|
+// System.out.println("-------- 此 path 校验成功:" + SaHolder.getRequest().getRequestPath());
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
+// System.out.println("-------- 此 path 校验失败:" + SaHolder.getRequest().getRequestPath());
|
|
|
|
+// throw e;
|
|
|
|
+// }
|
|
|
|
+// })).addPathPatterns("/**").excludePathPatterns(list);;
|
|
|
|
+// }
|
|
}
|
|
}
|