diff --git a/src/main/java/com/aida/seller/common/context/UserContext.java b/src/main/java/com/aida/seller/common/context/UserContext.java index 3b54b47..79defb3 100644 --- a/src/main/java/com/aida/seller/common/context/UserContext.java +++ b/src/main/java/com/aida/seller/common/context/UserContext.java @@ -24,6 +24,10 @@ public class UserContext { throw new UnauthorizedException("Gateway token verification failed"); } if (!"AIDA".equals(holder.getSource())) { + if ("BUYER".equals(holder.getSource())){ + AuthPrincipalVo buyerHolder = getBuyerHolder(); + return buyerHolder; + } throw new UnauthorizedException("Gateway token verification failed"); } return holder; @@ -52,6 +56,19 @@ public class UserContext { } 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() { AuthPrincipalVo holder = userHolder.get();