From b8341aa02a73e5866fc97dda01f990ec9628cf42 Mon Sep 17 00:00:00 2001 From: seongjunnoh Date: Tue, 20 Aug 2024 11:52:25 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20response=20redirect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../space_spring/controller/OAuthController.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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); } }