Skip to content

Commit

Permalink
Merge pull request #32 from codepzj/master
Browse files Browse the repository at this point in the history
fix: 生产环境token为空,跳过权限校验
  • Loading branch information
LiuYuYang01 authored Jan 31, 2025
2 parents bda4e11 + 8fbbfe5 commit 529a3e1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions blog/src/main/java/liuyuyang/net/aspect/PremNameAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ public void before(JoinPoint joinPoint) {
String token = request.getHeader("Authorization");
log.debug("Authorization Header: {}", token);

// 如果 token 为 null,跳过权限校验
if (token == null) {
log.info("Token为空,跳过权限校验");
return; // 跳过权限校验
}

// 去掉 Bearer 前缀
if (token != null && token.startsWith("Bearer ")) {
if (token.startsWith("Bearer ")) {
token = token.substring(7);
}

Expand Down Expand Up @@ -116,7 +122,7 @@ public void before(JoinPoint joinPoint) {
// 获取当前方法上的 @PremName 注解
private Optional<PremName> getMethodAnnotation(JoinPoint joinPoint) {
return Optional.ofNullable(getCurrentMethod(joinPoint))
.map(method -> method.getAnnotation(PremName.class));
.map(method -> method.getAnnotation(PremName.class));
}

// 获取当前执行的方法对象
Expand All @@ -135,4 +141,4 @@ private Method getCurrentMethod(JoinPoint joinPoint) {
}
return null;
}
}
}

0 comments on commit 529a3e1

Please sign in to comment.