<?php
namespace App\EventListener;
use App\Services\TokenManager;
use Symfony\Component\HttpFoundation\RequestStack;
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTDecodedEvent;
use Symfony\Component\HttpFoundation\JsonResponse;
class JWTDecodedListener
{
protected $tokenManager;
function __construct(
RequestStack $request,
TokenManager $tokenManager
)
{
$this->request = $request;
$this->tokenManager = $tokenManager;
}
/**
* @param JWTDecodedEvent $event
*
* @return void
*/
public function onJWTDecoded(JWTDecodedEvent $event)
{
$payload = $event->getPayload();
if (!$payload) return;
if ($this->tokenManager->isInvalidToken()) {
$event->markAsInvalid();
return;
}
return;
}
}