src/EventListener/AuthenticationFailureListener.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationFailureEvent;
  4. use Symfony\Component\HttpFoundation\JsonResponse;
  5. class AuthenticationFailureListener
  6. {
  7.     public function onAuthenticationFailure(AuthenticationFailureEvent $event): void
  8.     {
  9.         $data = [
  10.             'success' => false,
  11.             'message' => 'Identifiants invalides',
  12.             'error' => 'Authentication failed'
  13.         ];
  14.         error_log("AuthenticationFailureListener: Ã‰chec de connexion - " $event->getException()->getMessage());
  15.         $response = new JsonResponse($dataJsonResponse::HTTP_UNAUTHORIZED);
  16.         $event->setResponse($response);
  17.     }
  18. }