Skip to content

Commit

Permalink
Merge pull request #16 from Kyuwon-Choi/main
Browse files Browse the repository at this point in the history
feat: 카카오 로그인 시 userId 도 가져오게 수정
  • Loading branch information
Kyuwon-Choi authored Nov 20, 2024
2 parents 1ffb72e + 457c7b3 commit 7e44b22
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ public ResponseEntity<Map<String, Object>> login(@RequestParam("code") String co
kakaoService.registerNewUser(userInfo);
}

Long userId = kakaoService.getUserId(userInfo);

// 응답 데이터 생성
Map<String, Object> response = new HashMap<>();
response.put("accessToken", accessToken);
response.put("isFirstLogin", isFirstLogin);
response.put("userInfo", userInfo);
response.put("userId", userId);

return ResponseEntity.ok(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,11 @@ public String getKakaoLoginUrl() {
+ "&redirect_uri=" + redirectUri
+ "&response_type=code";
}

public Long getUserId(KakaoUserInfoResponse userInfo) {
return userRepository.findByKakaoId(userInfo.id().toString())
.map(User::getUserId)
.orElseThrow(() -> new RuntimeException("User not found"));
}

}

0 comments on commit 7e44b22

Please sign in to comment.