Skip to content

Commit

Permalink
Merge pull request #143 from KUIT-Space/develop
Browse files Browse the repository at this point in the history
24.08.20 ์ตœ์ข…๋ฐฐํฌ
  • Loading branch information
seongjunnoh authored Aug 20, 2024
2 parents 89e558f + ef55ee4 commit ea31a0e
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 ea31a0e

Please sign in to comment.