src/Controller/Client/SecurityController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Client;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. /**
  8.  * Controller used to manage the application security.
  9.  * See https://symfony.com/doc/current/cookbook/security/form_login_setup.html.
  10.  *
  11.  * @Route("/client")
  12.  */
  13. class SecurityController extends AbstractController
  14. {
  15.     /**
  16.      * @Route("/login", name="client_security_login")
  17.      *
  18.      * @param AuthenticationUtils $helper
  19.      */
  20.     public function login(AuthenticationUtils $helper): Response
  21.     {
  22.         // last authentication error (if any)
  23.         if ($error $helper->getLastAuthenticationError()) {
  24.             $this->addFlash('error'$error->getMessage());
  25.         }
  26.         return $this->render('client/security/login.html.twig', [
  27.             // last username entered by the user (if any)
  28.             'last_username' => $helper->getLastUsername(),
  29.         ]);
  30.     }
  31.     /**
  32.      * This is the route the user can use to logout.
  33.      *
  34.      * But, this will never be executed. Symfony will intercept this first
  35.      * and handle the logout automatically. See logout in config/packages/security.yaml
  36.      *
  37.      * @Route("/logout", name="client_security_logout")
  38.      */
  39.     public function logout(): void
  40.     {
  41.         throw new \Exception('This should never be reached!');
  42.     }
  43. }