src/EventListener/JWTNotFoundListener.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\JWTNotFoundEvent;
  6. use App\Model\Utility\RESTUtility;
  7. class JWTNotFoundListener {
  8.   private $rest;
  9.   public function __construct(RESTUtility $rest) {
  10.     $this->rest $rest;
  11.   }
  12.   /**
  13.    * @param JWTNotFoundEvent $event
  14.    */
  15.   public function onJWTNotFound(JWTNotFoundEvent $event) {
  16.     $response $this->rest->setResponse('Not authorized. Token missing.|User is not authorized to access this resource.'Response::HTTP_FORBIDDEN);
  17.     $event->setResponse($response);
  18.   }
  19. }