<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\component\Security\Core\Security;
class SecurityController extends AbstractController
{
#[Route("/login", "app_security_login")]
public function login(AuthenticationUtils $authenticationUtils): Response
{
if ($this->getUser()) {
return $this->redirectToRoute('homepage');
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
if ($error) {
$this->addFlash('danger', 'Identifiants invalides');
}
// last username entered by the user
$lastusername = $authenticationUtils->getLastUsername();
return $this->render('security/login.html.twig', ['last_username' => $lastusername]);
}
#[Route("/logout", "app_security_logout")]
public function logout(): void
{
}
}