안녕하세요.
spring security 인증 후 처리 부분에서 막혀서 질문드립니다.
axios를 통해서 security custom인증까지 완료된 상태입니다.
이후 처리를 해줘야 하는데 인증 성공/실패 시 다른 페이지로 이동이 되지 않습니다.
단순 jsp에서는 정상동작하는데 react + axios로 변경하려고 하니까 안되네요..
혹시 도와주실 수 있을까요?react axios 부분입니다.
axios("/loginproc", {
method: "POST",
data: formdata,
headers: {
"Content-Type": "multipart/form-data"
},
}).then((response => {
console.log(response.request.responseURL) // ??
})).catch((err => {
console.log(err)
}));
security 부분입니다.
http
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/loginproc")
.defaultSuccessUrl("/")
.successHandler(successUtil()) // 빈 만들어서 추가
.failureHandler(failureUtil()) // 빈 만들어서 추가
handler 부분입니다.
// failure
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
String erMsg = "인증 정보가 정확하지 않습니다.";
request.setAttribute("erMsg", erMsg); // 주고받기 확인 필
request.getRequestDispatcher(DEFAULT_FAILURE_URL).forward(request, response);
// response.sendRedirect(DEFAULT_FAILURE_URL);
}
// success
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
super.onAuthenticationSuccess(request, response, authentication);
}