<?php
declare(strict_types=1);
namespace Redatum\User\EventSubscriber;
use Gesdinet\JWTRefreshTokenBundle\Event\RefreshAuthenticationFailureEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use VisualCraft\RestBaseBundle\Problem\ProblemResponseFactory;
class RefreshEventsSubscriber implements EventSubscriberInterface
{
private ProblemResponseFactory $problemResponseFactory;
public function __construct(ProblemResponseFactory $problemResponseFactory)
{
$this->problemResponseFactory = $problemResponseFactory;
}
public static function getSubscribedEvents(): array
{
return [
'gesdinet.refresh_token_failure' => [
['processRefreshFailure'],
],
];
}
public function processRefreshFailure(RefreshAuthenticationFailureEvent $event): void
{
$exception = $event->getException();
$event->setResponse($this->problemResponseFactory->create($exception));
}
}