package cn.reghao.tnb.auth.app.security.handler;

import cn.reghao.tnb.auth.app.service.AccountTokenService;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.stereotype.Component;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/**
 * @author reghao
 * @date 2023-08-03 14:32:07
 */
@Component
public class LogoutHandlerImpl implements LogoutHandler {
    private final AccountTokenService accountTokenService;

    public LogoutHandlerImpl(AccountTokenService accountTokenService) {
        this.accountTokenService = accountTokenService;
    }

    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication auth) {
        accountTokenService.logout();
    }
}
