From 199abdee5eece6bc7d8f91d2501e978fa66a90a6 Mon Sep 17 00:00:00 2001 From: ddongseop Date: Tue, 12 Dec 2023 03:02:23 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EC=9C=A0=EC=A0=80=EA=B0=80=202?= =?UTF-8?q?=EB=B2=88=20=EC=83=9D=EC=84=B1=EB=90=98=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=9E=84=EC=8B=9C=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sopt/org/umbba/api/service/user/AuthService.java | 8 ++++++-- .../domain/domain/user/repository/UserRepository.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/service/user/AuthService.java b/umbba-api/src/main/java/sopt/org/umbba/api/service/user/AuthService.java index cd3923f8..e72c3164 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/service/user/AuthService.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/service/user/AuthService.java @@ -131,8 +131,12 @@ private User getUserById(Long userId) { } private User getUserBySocialAndSocialId(SocialPlatform socialPlatform, String socialId) { - return userRepository.findBySocialPlatformAndSocialId(socialPlatform, socialId) - .orElseThrow(() -> new CustomException(ErrorType.INVALID_USER)); + List users = userRepository.findBySocialPlatformAndSocialId(socialPlatform, socialId); + if (users.isEmpty()) { + throw new CustomException(ErrorType.INVALID_USER); + } + + return users.get(0); } private boolean isUserBySocialAndSocialId(SocialPlatform socialPlatform, String socialId) { diff --git a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/repository/UserRepository.java b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/repository/UserRepository.java index 5e717518..c4935cc2 100644 --- a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/repository/UserRepository.java +++ b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/repository/UserRepository.java @@ -16,7 +16,7 @@ public interface UserRepository extends Repository { // READ Optional findById(Long id); boolean existsBySocialPlatformAndSocialId(SocialPlatform socialPlatform, String socialId); - Optional findBySocialPlatformAndSocialId(SocialPlatform socialPlatform, String socialId); + List findBySocialPlatformAndSocialId(SocialPlatform socialPlatform, String socialId); Optional findByFcmToken(String fcmToken); // DELETE