src/EventListener/JWTAuthenticationFailureListener.php line 23

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\EventListener;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationFailureEvent;
  6. use App\Model\Utility\RESTUtility;
  7. class JWTAuthenticationFailureListener {
  8.   private $rest;
  9.   public function __construct(RESTUtility $rest) {
  10.     $this->rest $rest;
  11.   }
  12.   /**
  13.    * @param AuthenticationFailureEvent $event
  14.    */
  15.   public function onAuthenticationFailureResponse(AuthenticationFailureEvent $event) {
  16.     $errors['email'] = 'Incorrect email/password combination.|The password specified did not match with the user records and therefore he/she is not authorized to access the system.';
  17.     
  18.     $response $this->rest->setResponse($errorsResponse::HTTP_FORBIDDEN);
  19.     $event->setResponse($response);
  20.   }
  21. }