package ink.wgink.login.base.handler;

import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.Authentication;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: LogoutSuccessHandler
 * @Description: 注销成功
 * @Author: WangGeng
 * @Date: 2019/8/29 10:10 上午
 * @Version: 1.0
 **/
public class LogoutHandler implements org.springframework.security.web.authentication.logout.LogoutHandler {

    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        try {
            String redirectUri = request.getParameter("redirect_uri");
            if (!StringUtils.isBlank(redirectUri)) {
                response.sendRedirect(redirectUri);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
