<?php
declare(strict_types=1);
namespace App\Infrastructure\Controller\Security;
use App\Domain\Security\DTO\SecurityDTO;
use App\Infrastructure\Controller\Common\BaseController;
use App\Infrastructure\Form\Security\LoginType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends BaseController
{
/**
* @Route("/connexion", name="connexion")
*/
public function login(AuthenticationUtils $authenticationUtils): Response
{
$securityDTO = new SecurityDTO();
$form = $this->createForm(LoginType::class, $securityDTO);
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('Security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
'form' => $form->createView(),
]);
}
/**
* @Route("/deconnexion", name="deconnexion")
*/
public function logout()
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}