src/Controller/Security/SecurityController.php line 20

  1. <?php
  2. /*
  3. * ==============================================================
  4. *     Autor            :  Farid Benjomaa
  5. *     Modified by        :  
  6. *    COPYRIGHT (C) 2025, Media-Technologies
  7. * ==============================================================
  8. */
  9. namespace App\Controller\Security;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  14. class SecurityController extends AbstractController
  15. {
  16.     #[Route(path'/'name'app_login')]
  17.     public function login(AuthenticationUtils $authenticationUtils): Response
  18.     {
  19.         // if ($this->getUser()) {
  20.         //     return $this->redirectToRoute('target_path');
  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.     #[Route(path'/logout'name'app_logout')]
  29.     public function logout(): void
  30.     {
  31.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  32.     }
  33. }