Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24.08.20 최종배포 #143

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading