66import com .example .graduate .domain .user .exception .UserSuccessStatus ;
77import com .example .graduate .global .apiPayload .ApiResponse ;
88import com .example .graduate .global .apiPayload .exception .GeneralException ;
9- import io .swagger .v3 .oas .annotations .Operation ;
10- import io .swagger .v3 .oas .annotations .Parameter ;
119import io .swagger .v3 .oas .annotations .tags .Tag ;
1210import jakarta .servlet .http .HttpServletResponse ;
13- import jakarta .validation .constraints .Null ;
14- import java .io .IOException ;
1511import lombok .RequiredArgsConstructor ;
16- import lombok .extern .java .Log ;
17- import org .springframework .http .ResponseEntity ;
18- import org .springframework .web .bind .annotation .GetMapping ;
12+ import org .springframework .web .bind .annotation .PostMapping ;
1913import org .springframework .web .bind .annotation .RequestMapping ;
2014import org .springframework .web .bind .annotation .RequestParam ;
2115import org .springframework .web .bind .annotation .RestController ;
@@ -29,34 +23,17 @@ public class KakaoOAuthController {
2923 private final UserService userService ;
3024
3125 /**
32- * 카카오 로그인 페이지로 리다이렉트
26+ * 카카오 인가 코드로 사용자 인증 및 JWT 발급 처리
3327 */
34- @ Operation (
35- summary = "카카오 로그인 페이지 리다이렉트" ,
36- description = "카카오 로그인 페이지로 리다이렉트합니다." )
37- @ GetMapping
38- public void redirectToKakao (HttpServletResponse response ) throws IOException {
39- response .sendRedirect (kakaoService .getAuthorizationUrl ());
40- }
41-
42- /**
43- * 카카오 OAuth Callback 처리
44- */
45- @ Operation (
46- summary = "카카오 로그인 콜백" ,
47- description = "인가 코드를 기반으로 카카오 사용자 정보를 받아 JWT 토큰을 발급합니다." )
48- @ GetMapping ("/callback" )
49- public ApiResponse <Null > callback (
50- @ Parameter (description = "카카오 인가 코드" , required = true )
51- @ RequestParam ("code" ) String code ,
28+ @ PostMapping ("/login" )
29+ public ApiResponse <Void > kakaoLogin (
30+ @ RequestParam (value = "code" , required = true ) String code ,
5231 HttpServletResponse response ) {
5332 try {
5433 String token = kakaoService .getAccessToken (code );
5534 var userInfo = kakaoService .getUserInfo (token );
5635
57- // accessToken은 응답 헤더로, refreshToken은 HttpOnly 쿠키로 전송
5836 userService .loginOrRegister (userInfo , response );
59-
6037 return ApiResponse .of (UserSuccessStatus .SUCCESS_LOGIN );
6138
6239 } catch (Exception e ) {
0 commit comments