src/Controller/SecurityController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  6. class SecurityController extends AbstractController
  7. {
  8.     /**
  9.      * @Route("/login", name="app_login")
  10.      *
  11.      * @param AuthenticationUtils $authenticationUtils
  12.      * @return \Symfony\Component\HttpFoundation\Response
  13.      */
  14.     public function login(AuthenticationUtils $authenticationUtils)
  15.     {
  16.         // get the login error if there is one
  17.         $error $authenticationUtils->getLastAuthenticationError();
  18.         // last username entered by the user
  19.         $lastUsername $authenticationUtils->getLastUsername();
  20.         return $this->render('security/login.html.twig', [
  21.             'last_username' => $lastUsername,
  22.             'error' => $error,
  23.         ]);
  24.     }
  25.     /**
  26.      * @Route("/logout", name="app_logout")
  27.      *
  28.      * @throws \Exception
  29.      */
  30.     public function logout()
  31.     {
  32.         throw new \Exception('Will be intercepted before getting here');
  33.     }
  34. }