src/Controller/SecurityController.php line 24

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the ArtHotel Naquera website.
  5.  *
  6.  * For the full copyright and license information,
  7.  * please read the LICENSE.md file that was distributed with this source code.
  8.  *
  9.  * Copyright (c) 2023.
  10.  */
  11. namespace App\Controller;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  16. class SecurityController extends AbstractController
  17. {
  18.     #[Route('/')]
  19.     public function indexNoLocale(): Response
  20.     {
  21.         return $this->redirectToRoute('index', ['_locale' => $_ENV['APP_DEFAULT_LANGUAGE']]);
  22.     }
  23.     #[Route(path'/login'name'app_login')]
  24.     public function login(AuthenticationUtils $authenticationUtils): Response
  25.     {
  26.         // if ($this->getUser()) {
  27.         //     return $this->redirectToRoute('target_path');
  28.         // }
  29.         // get the login error if there is one
  30.         $error $authenticationUtils->getLastAuthenticationError();
  31.         // last username entered by the user
  32.         $lastUsername $authenticationUtils->getLastUsername();
  33.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  34.     }
  35.     #[Route(path'/logout'name'app_logout')]
  36.     public function logout(): void
  37.     {
  38.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  39.     }
  40. }