src/Controller/LoginController.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. use Symfony\Component\Security\Core\Security;
  8. class LoginController extends AbstractController
  9. {
  10.     #[Route('/{_locale}/login',
  11.         locale"en",
  12.         format"html",
  13.         requirements: ["_locale" => "en|es|ca""_format" => "html|xml", ],
  14.         defaults: ["_locale" => "en"],  name'app_login')]
  15.     public function index(AuthenticationUtils $authenticationUtilsSecurity $security): Response
  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.         $user $security->getUser();
  22.         
  23.         /*if($user){
  24.             return $this->redirectToRoute('home');
  25.         }*/
  26.         return $this->render('Security/login.html.twig', [
  27.             'controller_name' => 'LoginController',
  28.             'last_username' => $lastUsername,
  29.             'error'         => $error,
  30.         ]);
  31.     }
  32.     /**
  33.      * @Route("/logout", name="app_logout")
  34.      */
  35.     public function logout()
  36.     {
  37.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  38.     }
  39. }