src/Security/PasswordlessAuthenticator.php line 45

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: grego
  5.  * Date: 27/01/2026
  6.  * Time: 11:30
  7.  */
  8. namespace App\Security;
  9. use Symfony\Component\HttpFoundation\RedirectResponse;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  12. use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
  13. use Symfony\Component\Security\Core\User\UserProviderInterface;
  14. use Symfony\Component\Security\Core\User\UserInterface;
  15. use Symfony\Component\Security\Core\Exception\AuthenticationException;
  16. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
  19. use Symfony\Component\Security\Http\Util\TargetPathTrait;
  20. class PasswordlessAuthenticator extends AbstractAuthenticator implements AuthenticationEntryPointInterface
  21. {
  22.     use TargetPathTrait;
  23.     public function start(
  24.         Request $request,
  25.         AuthenticationException $authException null
  26.     ): RedirectResponse {
  27.         // 🔁 Redirection vers la page de login
  28.         return new RedirectResponse('/auth/login');
  29.     }
  30.     public function supports(Request $request): bool
  31.     {
  32.         // uniquement pour /auth et /form
  33.         return true;
  34.     }
  35.     public function authenticate(Request $request)
  36.     {
  37.         // On ne fait rien ici
  38.         // Le login est déclenché manuellement dans le controller
  39.         throw new AuthenticationException('Not used');
  40.     }
  41.     public function onAuthenticationSuccess(Request $requestTokenInterface $tokenstring $firewallName): ?Response {
  42.         return null;
  43.     }
  44.     public function onAuthenticationFailure(Request $requestAuthenticationException $exception): ?Response {
  45.         return null;
  46.     }
  47. }