<?php
declare(strict_types = 1);
namespace App\EventListener;
use Symfony\Component\HttpFoundation\Response;
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTInvalidEvent;
use App\Model\Utility\RESTUtility;
class JWTInvalidListener {
private $rest;
public function __construct(RESTUtility $rest) {
$this->rest = $rest;
}
/**
* @param JWTNotFoundEvent $event
*/
public function onJWTInvalid(JWTInvalidEvent $event) {
$response = $this->rest->setResponse('Not authorized. Token is invalid.|User is not authorized to access this resource.', Response::HTTP_FORBIDDEN);
$event->setResponse($response);
}
}