src/Controller/SecurityController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  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.  *
  9.  * @Route("{_locale}", requirements={"_locale": "en|fr"})
  10.  */
  11.  
  12. class SecurityController extends AbstractController
  13. {
  14.     /**
  15.      * @Route("/", name="login")
  16.      */
  17.     public function login(AuthenticationUtils $authenticationUtils): Response
  18.     {
  19.         if ($this->getUser()) {
  20.             return $this->redirectToRoute('authenticated_offers');
  21.         }
  22.         // get the login error if there is one
  23.         $error $authenticationUtils->getLastAuthenticationError();
  24.         // last username entered by the user
  25.         $lastUsername $authenticationUtils->getLastUsername();
  26.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  27.     }
  28.     /**
  29.      * @Route("/logout", name="logout")
  30.      */
  31.     public function logout()
  32.     {
  33.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  34.     }
  35. }