public function onCoreRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
// Exclude path
if ($this->excludePattern !== null && preg_match('#' . $this->excludePattern . '#', $request->getPathInfo())) {
return;
}
// Check if security token is supported
$token = $this->tokenStorage->getToken();
if (!$this->isTokenSupported($token)) {
return;
}
// Forward to two-factor provider
// Providers can create a response object
$context = $this->authenticationContextFactory->create($request, $token);
$response = $this->authHandler->requestAuthenticationCode($context);
// Set the response (if there is one)
if ($response instanceof Response) {
$event->setResponse($response);
}
}