From 3a6470757fa7e3dd36f3871992fc4624c3c1bf6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=AF=E1=86=AB=E1=84=8C=E1=85=A1=E1=86=BC?= =?UTF-8?q?=E1=84=89=E1=85=AE=E1=86=AB?= Date: Tue, 12 Aug 2025 22:16:13 +0900 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=8B=9C=20authId=EC=9D=98=20Bearer=20=EC=A0=91?= =?UTF-8?q?=EB=91=90=EC=82=AC=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../terningserver/auth/application/AuthService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/terning/terningserver/auth/application/AuthService.java b/src/main/java/org/terning/terningserver/auth/application/AuthService.java index 1b360cc..c4aef54 100644 --- a/src/main/java/org/terning/terningserver/auth/application/AuthService.java +++ b/src/main/java/org/terning/terningserver/auth/application/AuthService.java @@ -39,6 +39,8 @@ public class AuthService { private final ApplicationEventPublisher eventPublisher; private final NotificationUserClient notificationUserClient; private final FilterRepository filterRepository; + private static final String TOKEN_PREFIX = "Bearer "; + @Transactional public SignInResponse signIn(String socialAccessToken, SignInRequest request) { @@ -61,11 +63,16 @@ public SignInResponse signIn(String socialAccessToken, SignInRequest request) { @Transactional public SignUpResponse signUp(String authId, SignUpRequest request) { - if (userRepository.existsByAuthIdAndAuthType(authId, request.authType())) { + String resolvedAuthId = authId; + if (resolvedAuthId != null && resolvedAuthId.startsWith(TOKEN_PREFIX)) { + resolvedAuthId = resolvedAuthId.substring(TOKEN_PREFIX.length()); + } + + if (userRepository.existsByAuthIdAndAuthType(resolvedAuthId, request.authType())) { throw new AuthException(AuthErrorCode.USER_ALREADY_EXIST); } - User userToSave = User.from(authId, request); + User userToSave = User.from(resolvedAuthId, request); userRepository.save(userToSave); Token token = jwtProvider.generateTokens(userToSave.getId());