<?php

namespace App\Controller\Auth;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

#[Route("/auth", name: "auth_")]
class SecurityController extends AbstractController
{
    #[Route('/login', name: 'login')]
    public function login(Request $request, AuthenticationUtils $authUtils): Response
    {
        if ($this->getUser()) {
            return $this->redirectToRoute('admin_home');
        }

        $error = $authUtils->getLastAuthenticationError();
        $lastUserName = $authUtils->getLastUsername();
        return $this->render('admin/auth/security/login.html.twig', [
                'error' => $error,
                'lastUserName' => $lastUserName
            ]
        );
    }

    #[Route('/logout', name: 'logout')]
    public function logout() {}
}
