Browse Source

[feat]

1、修改失效前端会提示一堆token问题
master
杨威 2 months ago
parent
commit
7fec391434
  1. 12
      dk-gateway/src/main/java/org/dromara/gateway/filter/AuthFilter.java

12
dk-gateway/src/main/java/org/dromara/gateway/filter/AuthFilter.java

@ -69,8 +69,16 @@ public class AuthFilter {
// } // }
}); });
}).setError(e -> { }).setError(e -> {
if (e instanceof NotLoginException) { if (e instanceof NotLoginException notLoginException) {
return SaResult.error(e.getMessage()).setCode(HttpStatus.UNAUTHORIZED); return switch (notLoginException.getType()) {
case NotLoginException.INVALID_TOKEN ->
SaResult.error(NotLoginException.INVALID_TOKEN_MESSAGE).setCode(HttpStatus.UNAUTHORIZED);
case NotLoginException.TOKEN_TIMEOUT ->
SaResult.error(NotLoginException.TOKEN_TIMEOUT_MESSAGE).setCode(HttpStatus.UNAUTHORIZED);
case NotLoginException.TOKEN_FREEZE ->
SaResult.error(NotLoginException.TOKEN_FREEZE_MESSAGE).setCode(HttpStatus.UNAUTHORIZED);
default -> SaResult.error(e.getMessage()).setCode(HttpStatus.UNAUTHORIZED);
};
} }
return SaResult.error("认证失败,无法访问系统资源").setCode(HttpStatus.UNAUTHORIZED); return SaResult.error("认证失败,无法访问系统资源").setCode(HttpStatus.UNAUTHORIZED);
}); });

Loading…
Cancel
Save