Skip to content

Commit

Permalink
Merge pull request #159 from Team-Motivoo/fix/#158-apple_login_valida…
Browse files Browse the repository at this point in the history
…tion

[FIX] client Id 수정 및 OauthService 로직 개선 #158
  • Loading branch information
jun02160 committed Apr 16, 2024
2 parents bf1be17 + 2eb5e24 commit 0fc1a5b
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,24 @@ public LoginResult login(OauthTokenCommand tokenRequest) {
OAuthPlatformMemberResult applePlatformMember = appleLoginService.getApplePlatformMember(tokenRequest.accessToken());

List<User> 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);
}
Expand Down

0 comments on commit 0fc1a5b

Please sign in to comment.