package top.imwork.window.silos.security.handler;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * Copyright (C), 2015-2025
 * FileName: SecurityAuthenticationSuccessHandler
 * Author<作者姓名>:   stars
 * CreateTime<创建时间>:   2025/12/10 14:15
 * UpdateTime<修改时间>:   2025/12/10 14:15
 * Description〈功能简述〉: 登录成功处理器
 * History<历史描述>:
 * Since<版本号>: 1.0.0
 */
@Component
public class SecurityAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        // 可以在这里添加自定义逻辑，例如重定向到某个页面
        response.sendRedirect("/index.html"); // 重定向到首页
    }
}