Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SaInterceptor拦截器中功能未生效 #679

Open
hanweidong opened this issue Sep 13, 2024 · 0 comments
Open

SaInterceptor拦截器中功能未生效 #679

hanweidong opened this issue Sep 13, 2024 · 0 comments

Comments

@hanweidong
Copy link

使用版本:

1.39.0

报错信息:

我想在SaInterceptor中对越权访问的用户记录日志,但是代码好像没有生效。

希望结果:

对越权访问的用户记录日志

复现步骤:

@OverRide
public void addInterceptors(InterceptorRegistry registry) {
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
registry.addInterceptor(new SaInterceptor(handle -> {
Object loginId = StpUtil.getLoginId();
log.info("loginId is {}", loginId);
try {
Account account = accountService.findById((String) loginId);
String role = account.getRoleType().name();

    SaRouter.match("/**").check(r -> {
      StpUtil.checkRole(role);
    });
  } catch (NotRoleException | CommonException e){
    log.info("not role exception.");
  }
})).addPathPatterns("/**");

}

< 备注:如果复现步骤比较复杂,请将 demo 上传到 gitee 并留下地址 >

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant