11package com .back .global .security ;
22
3- import com .back .domain .user .service .UserService ;
4- import com .back .global .jwt .JwtUtil ;
5- import com .back .global .rq .Rq ;
3+ import com .back .domain .user .service .UserAuthService ;
64import jakarta .servlet .ServletException ;
75import jakarta .servlet .http .HttpServletRequest ;
86import jakarta .servlet .http .HttpServletResponse ;
1311import org .springframework .stereotype .Component ;
1412
1513import java .io .IOException ;
16- import java .util .concurrent .TimeUnit ;
1714
1815@ Component
1916@ RequiredArgsConstructor
2017public class CustomOAuth2LoginSuccessHandler implements AuthenticationSuccessHandler {
21- private final Rq rq ;
22- private final JwtUtil jwtUtil ;
23- private final UserService userService ;
18+
19+ private final UserAuthService userAuthService ;
2420
2521 @ Value ("${FRONTEND_URL}" )
2622 private String frontendUrl ;
@@ -29,11 +25,8 @@ public class CustomOAuth2LoginSuccessHandler implements AuthenticationSuccessHan
2925 public void onAuthenticationSuccess (HttpServletRequest request , HttpServletResponse response , Authentication authentication ) throws IOException , ServletException {
3026 SecurityUser securityUser = (SecurityUser ) authentication .getPrincipal ();
3127
32- // Access Token 생성
33- String accessToken = jwtUtil .generateAccessToken (securityUser .getId (), securityUser .getEmail ());
34-
35- // 쿠키에 토큰 저장
36- rq .setCrossDomainCookie ("accessToken" , accessToken , (int ) TimeUnit .MINUTES .toSeconds (20 ));
28+ // Access Token과 Refresh Token 발급
29+ userAuthService .issueTokens (response , securityUser .getId (), securityUser .getEmail ());
3730
3831 // 프론트엔드로 리다이렉트
3932 String redirectUrl = frontendUrl + "/oauth/success" ;
0 commit comments