src/Controller/Admin/SecurityController.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. class SecurityController extends AbstractController
  9. {
  10.     #[Route(path"/admin/login"name"admin_app_login")]
  11.     public function login(
  12.         AuthenticationUtils $authenticationUtils
  13.     ): Response {
  14.         if ($this->getUser()) {
  15.             return $this->redirectToRoute('admin_dashboard');
  16.         }
  17.         // get the login error if there is one
  18.         $error $authenticationUtils->getLastAuthenticationError();
  19.         // last username entered by the user
  20.         $lastUsername $authenticationUtils->getLastUsername();
  21.         return $this->render('security/login.html.twig',
  22.             [
  23.                 'last_username' => $lastUsername,
  24.                 'error' => $error
  25.             ]);
  26.     }
  27.     /**
  28.      * @Route("/logout", name="app_logout")
  29.      */
  30.     public function logout(
  31.     ): void
  32.     {
  33.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  34.     }
  35. }