@Component
@Slf4j
public class AjaxAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
@Override
public void onAuthenticationSuccess(HttpServletRequest request,
HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
Account account = (Account) authentication.getPrincipal();
((AjaxAuthenticationToken) authentication).setDetails(new WebAuthenticationDetails(request));
response.setStatus(HttpStatus.OK.value());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
/* ObjectMapper 가 JSON 형식으로 변환해서 Response 를 이용하여 Client 에 전달 */
new ObjectMapper().writeValue(response.getWriter(), "loginOK");
}
}
위 코드처럼 AuthenticationSuccessHandler 부분에
((AjaxAuthenticationToken) authentication).setDetails(new WebAuthenticationDetails(request));
이 코드 한줄 넣어주시면 정상적으로 작동 될거에요.