diff --git a/src/main/java/space/space_spring/controller/OAuthController.java b/src/main/java/space/space_spring/controller/OAuthController.java index 591a9ce4..631e0414 100644 --- a/src/main/java/space/space_spring/controller/OAuthController.java +++ b/src/main/java/space/space_spring/controller/OAuthController.java @@ -15,6 +15,8 @@ import space.space_spring.response.BaseResponse; import space.space_spring.service.OAuthService; +import java.io.IOException; + @RestController @RequiredArgsConstructor @RequestMapping("/oauth") @@ -36,7 +38,7 @@ public class OAuthController { * 유저가 카카오 로그인 동의 시 호출될 콜백 함수 */ @GetMapping("/callback/kakao") - public BaseResponse kakaoCallback(@RequestParam(name = "code") String code, HttpServletResponse response) { + public void kakaoCallback(@RequestParam(name = "code") String code, HttpServletResponse response) throws IOException { // TODO 1. 인가코드 받기 // 카카오 인증 서버는 서비스 서버의 Redirect URI로 인가 코드를 전달함 @@ -71,6 +73,14 @@ public BaseResponse kakaoCallback(@RequestParam(name = "code response.setHeader("Authorization", "Bearer " + jwtOAuthLogin); log.info("jwtOAuthLogin = {}", jwtOAuthLogin); - return new BaseResponse<>(new OAuthLoginResponse(userByOAuthInfo.getUserId())); + // Construct the redirect URL with the JWT and userId as query parameters + String redirectUrl = String.format( + "https://kuit-space.github.io/KUIT-Space-front/login?jwt=Bearer %s&userId=%s", + jwtOAuthLogin, + userByOAuthInfo.getUserId() + ); + + // Redirect to the specified URL + response.sendRedirect(redirectUrl); } }