/**
* Call TwoFactorProviderRegistry, set trusted computer cookie if requested.
*
* @param AuthenticationContextInterface $context
*
* @return Response|null
*/
public function requestAuthenticationCode(AuthenticationContextInterface $context)
{
$request = $context->getRequest();
$user = $context->getUser();
$context->setUseTrustedOption($this->useTrustedOption);
// Set trusted flag
$response = $this->authHandler->requestAuthenticationCode($context);
// On response validate if trusted cookie should be set
if ($response instanceof Response) {
// Set trusted cookie
if ($context->isAuthenticated() && $context->useTrustedOption() && $request->get($this->trustedName)) {
$cookie = $this->cookieManager->createTrustedCookie($request, $user);
$response->headers->setCookie($cookie);
}
return $response;
}
return null;
}