Skip to content

Commit

Permalink
fix: Kakao Login
Browse files Browse the repository at this point in the history
  • Loading branch information
DDonghyeo committed Jan 9, 2024
1 parent 5217c03 commit 4ab10de
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@Slf4j
@RestController
@RequestMapping("")
@RequestMapping("/login")
public class KakaoLoginController {

@Value("${kakao.client_id}")
Expand All @@ -38,22 +38,13 @@ public class KakaoLoginController {

private UriComponentsBuilder uriBuilder;

@GetMapping("/callback")
public ResponseEntity<?> callback(@RequestParam("code") String code, HttpServletRequest request, HttpServletResponse response) throws IOException {
@GetMapping("/kakao")
public ResponseEntity<?> login(@RequestParam("code") String code) throws IOException {
UserRegisterDto.KakaoResponseDto userToken = kakaoService.getAccessTokenFromKakao(client_id, code);
UserRegisterDto.KakaoUserRegisterDto userInfo = kakaoService.getUserInfo(userToken.getAccessToken());
if (!userService.isUserByKakaoId(userInfo.getId())) {
userService.registerKakao(userInfo);
}

// response.sendRedirect("http://localhost:5500");

Cookie cookie = new Cookie("accessToken", userToken.getAccessToken());
response.addCookie(cookie);
Cookie cookie2 = new Cookie("refreshToken", userToken.getRefreshToken());
response.addCookie(cookie2);


return ResponseEntity.ok(userToken.getAccessToken());
return ResponseEntity.ok(userToken);
}
}

0 comments on commit 4ab10de

Please sign in to comment.