$passport =
$event->
getPassport();
if (!
$passport->
hasBadge(CsrfTokenBadge::
class)) { return;
} /** @var CsrfTokenBadge $badge */
$badge =
$passport->
getBadge(CsrfTokenBadge::
class);
if ($badge->
isResolved()) { return;
} $csrfToken =
new CsrfToken($badge->
getCsrfTokenId(),
$badge->
getCsrfToken());
if (false ===
$this->csrfTokenManager->
isTokenValid($csrfToken)) { throw new InvalidCsrfTokenException('Invalid CSRF token.'
);
} $badge->
markResolved();
} public static function getSubscribedEvents(): array
{ return [CheckPassportEvent::
class => ['checkPassport', 512
]];
}