src/Controller/SecurityController.php line 19

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\RateLimiter\RateLimiterFactory;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use App\Repository\CategorieRepository;
  10. class SecurityController extends AbstractController
  11. {
  12.     #[Route(path'/login'name'app_login')]
  13.     public function login(AuthenticationUtils $authenticationUtils CategorieRepository $categorieRepository): Response
  14.     {
  15.          if ($this->getUser()) {
  16.             return $this->redirectToRoute('app_accueil');
  17.          }
  18.         $categories $categorieRepository->findAll();
  19.         $error $authenticationUtils->getLastAuthenticationError();
  20.         $lastUsername $authenticationUtils->getLastUsername();
  21.         return $this->render('security/login.html.twig', [
  22.             'last_username' => $lastUsername,  
  23.             'categories' => $categories
  24.             'error' => $error
  25.         ]);
  26.     }
  27.     #[Route(path'/logout'name'app_logout')]
  28.     public function logout(): void
  29.     {
  30.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  31.     }
  32. }