Skip to content

Commit

Permalink
Merge pull request #142 from KUIT-Space/hotfix/#141/카카오-로그인-수정
Browse files Browse the repository at this point in the history
fix : 카카오로그인 response redirect
  • Loading branch information
seongjunnoh authored Aug 20, 2024
2 parents 1162563 + b8341aa commit ef55ee4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/space/space_spring/controller/OAuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import space.space_spring.response.BaseResponse;
import space.space_spring.service.OAuthService;

import java.io.IOException;

@RestController
@RequiredArgsConstructor
@RequestMapping("/oauth")
Expand All @@ -36,7 +38,7 @@ public class OAuthController {
* 유저가 카카오 로그인 동의 시 호출될 콜백 함수
*/
@GetMapping("/callback/kakao")
public BaseResponse<OAuthLoginResponse> kakaoCallback(@RequestParam(name = "code") String code, HttpServletResponse response) {
public void kakaoCallback(@RequestParam(name = "code") String code, HttpServletResponse response) throws IOException {

// TODO 1. 인가코드 받기
// 카카오 인증 서버는 서비스 서버의 Redirect URI로 인가 코드를 전달함
Expand Down Expand Up @@ -71,6 +73,14 @@ public BaseResponse<OAuthLoginResponse> 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);
}
}

0 comments on commit ef55ee4

Please sign in to comment.