diff --git a/tecobrary-admin/src/main/java/com/woowacourse/tecobrary/admin/handler/AdminAuthSuccessHandler.java b/tecobrary-admin/src/main/java/com/woowacourse/tecobrary/admin/handler/AdminAuthSuccessHandler.java new file mode 100644 index 0000000..0c2452f --- /dev/null +++ b/tecobrary-admin/src/main/java/com/woowacourse/tecobrary/admin/handler/AdminAuthSuccessHandler.java @@ -0,0 +1,26 @@ +package com.woowacourse.tecobrary.admin.handler; + +import com.woowacourse.tecobrary.admin.web.AdminUserDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Slf4j +@Component +@RequiredArgsConstructor +public class AdminAuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler { + + @Override + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { + super.onAuthenticationSuccess(request, response, authentication); + AdminUserDto adminUserDto = (AdminUserDto) authentication.getPrincipal(); + log.info("로그인 성공={}", adminUserDto); + } +}