package com.style24.admin.support.security.handler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
import org.springframework.stereotype.Component;

import com.style24.admin.support.security.session.TsaSession;

import lombok.extern.slf4j.Slf4j;

/**
 * 로그아웃 성공 시 호출되는 Handler
 * 
 * @author gagamel
 * @since 2020. 10. 5
 */
@Component
@Slf4j
public class TsaLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler {

	@Override
	public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
		TsaSession.invalidate(request);
		response.sendRedirect("/");
	}

}
