diff --git a/src/main/java/com/dnd/gongmuin/security/handler/CustomAuthenticationEntryPoint.java b/src/main/java/com/dnd/gongmuin/security/handler/CustomAuthenticationEntryPoint.java index 19a73863..2b18bd4d 100644 --- a/src/main/java/com/dnd/gongmuin/security/handler/CustomAuthenticationEntryPoint.java +++ b/src/main/java/com/dnd/gongmuin/security/handler/CustomAuthenticationEntryPoint.java @@ -1,6 +1,7 @@ package com.dnd.gongmuin.security.handler; import java.io.IOException; +import java.util.Arrays; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; @@ -20,6 +21,7 @@ public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { log.error("비인가 사용자 요청 -> 예외 발생 : {}", authException.getMessage()); + log.error(Arrays.toString(authException.getStackTrace())); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401 Unauthorized response.setContentType("application/json"); diff --git a/src/main/java/com/dnd/gongmuin/security/handler/CustomOauth2SuccessHandler.java b/src/main/java/com/dnd/gongmuin/security/handler/CustomOauth2SuccessHandler.java index cc44d4e4..e6798b13 100644 --- a/src/main/java/com/dnd/gongmuin/security/handler/CustomOauth2SuccessHandler.java +++ b/src/main/java/com/dnd/gongmuin/security/handler/CustomOauth2SuccessHandler.java @@ -19,9 +19,11 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Component @RequiredArgsConstructor +@Slf4j public class CustomOauth2SuccessHandler implements AuthenticationSuccessHandler { private final MemberRepository memberRepository; @@ -37,15 +39,20 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo Authentication authentication) throws IOException { CustomOauth2User customOauth2User = (CustomOauth2User)authentication.getPrincipal(); + log.error("CustomOauth2User = ", customOauth2User.getEmail()); String socialEmail = customOauth2User.getEmail(); Member findmember = memberRepository.findBySocialEmail(socialEmail) .orElseThrow(() -> new NotFoundException(MemberErrorCode.NOT_FOUND_MEMBER)); + log.error("findmember = ", findmember.toString()); + String token = tokenProvider.generateAccessToken(findmember, customOauth2User, new Date()); tokenProvider.generateRefreshToken(findmember, customOauth2User, new Date()); + log.error("token = ", token); response.addCookie(cookieUtil.createCookie(token)); + log.error("response = ", response.getHeader("Set-Cookie")); if (isRoleGuest(findmember.getRole())) { response.sendRedirect(REDIRECTION_SIGNUP);