From 5dd13caf50fc330f5d5f77fc31e525bddf115659 Mon Sep 17 00:00:00 2001 From: litianxiang Date: Wed, 3 Jun 2026 18:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=AF=AD=E8=A8=80=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aida/seller/common/context/UserContext.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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();