<?php
/**
* Created by PhpStorm.
* User: grego
* Date: 27/01/2026
* Time: 11:30
*/
namespace App\Security;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\Security\Http\Util\TargetPathTrait;
class PasswordlessAuthenticator extends AbstractAuthenticator implements AuthenticationEntryPointInterface
{
use TargetPathTrait;
public function start(
Request $request,
AuthenticationException $authException = null
): RedirectResponse {
// 🔁 Redirection vers la page de login
return new RedirectResponse('/auth/login');
}
public function supports(Request $request): bool
{
// uniquement pour /auth et /form
return true;
}
public function authenticate(Request $request)
{
// On ne fait rien ici
// Le login est déclenché manuellement dans le controller
throw new AuthenticationException('Not used');
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response {
return null;
}
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response {
return null;
}
}