src/Controller/SecurityController.php line 23

  1. <?php
  2. namespace App\Controller;
  3. use App\Form\SecurityForm;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. final class SecurityController extends AbstractController
  9. {
  10.     private AuthenticationUtils $authenticationUtils;
  11.     public function __construct(AuthenticationUtils $authenticationUtils)
  12.     {
  13.         $this->authenticationUtils $authenticationUtils;
  14.     }
  15.     /**
  16.      * @Route("/admin/login", name="login")
  17.      */
  18.     public function login(): Response
  19.     {
  20.         $form $this->createForm(SecurityForm::class, [
  21.             'email' => $this->authenticationUtils->getLastUsername(),
  22.         ]);
  23.         return $this->render('security/login.html.twig', [
  24.             'last_username' => $this->authenticationUtils->getLastUsername(),
  25.             'form' => $form->createView(),
  26.             'error' => $this->authenticationUtils->getLastAuthenticationError(),
  27.         ]);
  28.     }
  29.     /**
  30.      * @Route("/admin/logout", name="logout")
  31.      */
  32.     public function logout(): void
  33.     {
  34.         // Left empty intentionally because this will be handled by Symfony.
  35.     }
  36. }