报错语言适配

This commit is contained in:
litianxiang
2026-06-03 18:05:04 +08:00
parent 4beff1d870
commit 5dd13caf50

View File

@@ -24,6 +24,10 @@ public class UserContext {
throw new UnauthorizedException("Gateway token verification failed"); throw new UnauthorizedException("Gateway token verification failed");
} }
if (!"AIDA".equals(holder.getSource())) { if (!"AIDA".equals(holder.getSource())) {
if ("BUYER".equals(holder.getSource())){
AuthPrincipalVo buyerHolder = getBuyerHolder();
return buyerHolder;
}
throw new UnauthorizedException("Gateway token verification failed"); throw new UnauthorizedException("Gateway token verification failed");
} }
return holder; return holder;
@@ -52,6 +56,19 @@ public class UserContext {
} }
return holder.getId(); return holder.getId();
} }
public static AuthPrincipalVo getBuyerHolder() {
AuthPrincipalVo holder = userHolder.get();
if (holder == null) {
if (optionalAuth.get()) {
return null;
}
throw new UnauthorizedException("Gateway token verification failed");
}
if (!"BUYER".equals(holder.getSource())) {
throw new UnauthorizedException("Gateway token verification failed");
}
return holder;
}
public static Long getBuyerIdSafely() { public static Long getBuyerIdSafely() {
AuthPrincipalVo holder = userHolder.get(); AuthPrincipalVo holder = userHolder.get();