Skip to content

Commit

Permalink
♻️ refactor login logic
Browse files Browse the repository at this point in the history
  • Loading branch information
HaiSeong committed Jul 28, 2024
1 parent ad29037 commit 2fd419b
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ public GoogleLoginResponse loginWithGoogle(GoogleLoginRequest googleLoginRequest
FirebaseToken decodedToken = decodeIdToken(googleLoginRequest.idToken());
String email = decodedToken.getEmail();

if (!userRepository.existsByEmail(email)) {
User user = userRepository.findByEmail(email).orElse(null);

if (user == null) {
return new GoogleLoginResponse(false, null);
}
User user = userRepository.findByEmail(email).orElseThrow();
String accessToken = jwtTokenManager.createToken(new TokenPayload(user.getId(), user.getEmail()));

String accessToken = jwtTokenManager.createToken(new TokenPayload(user.getId(), user.getEmail()));
return new GoogleLoginResponse(true, accessToken);
}

Expand Down

0 comments on commit 2fd419b

Please sign in to comment.