From 2eb5e24bd207252dbf392bf04a1ad364346f74fe Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 16 Apr 2024 23:50:06 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20bugfix:=20client=20Id=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20OauthService=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B0=9C=EC=84=A0=20#158?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/auth/service/OauthService.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/auth/service/OauthService.java b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/auth/service/OauthService.java index 3cb4922..01ee123 100644 --- a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/auth/service/OauthService.java +++ b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/auth/service/OauthService.java @@ -88,19 +88,24 @@ public LoginResult login(OauthTokenCommand tokenRequest) { OAuthPlatformMemberResult applePlatformMember = appleLoginService.getApplePlatformMember(tokenRequest.accessToken()); List userEntity = userRetriever.getUsersBySocialId(applePlatformMember.platformId()); + log.info("userEntity: {}", userEntity.size()); + + User user; //처음 로그인 하거나 탈퇴한 경우 -> 회원가입 - if (userEntity == null || isWithdrawn(userEntity)) { - User user = saveUser(null, applePlatformMember.platformId(), socialPlatform, tokenRequest, refreshToken); + if (userEntity.isEmpty() || isWithdrawn(userEntity)) { + user = saveUser(null, applePlatformMember.platformId(), socialPlatform, tokenRequest, refreshToken); + } + userEntity = userRetriever.getUsersBySocialId(applePlatformMember.platformId()); + user = userEntity.get(0); - //로그인 - updateRefreshToken(user, refreshToken); - String accessToken = jwtTokenProvider.createAccessToken(new UserAuthentication(user.getId(),null,null)); + //로그인 + updateRefreshToken(user, refreshToken); + String accessToken = jwtTokenProvider.createAccessToken(new UserAuthentication(user.getId(),null,null)); - boolean isFinishedOnboarding = healthRetriever.existsHealthByUser(user); - boolean isMatched = user.getParentchild() != null && user.getParentchild().isMatched(); + boolean isFinishedOnboarding = healthRetriever.existsHealthByUser(user); + boolean isMatched = user.getParentchild() != null && user.getParentchild().isMatched(); - return LoginResult.of(user, accessToken, refreshToken, isFinishedOnboarding, isMatched); - } + return LoginResult.of(user, accessToken, refreshToken, isFinishedOnboarding, isMatched); } throw new UserException(INVALID_SOCIAL_PLATFORM); }