/**
* Call TwoFactorProviderRegistry, set trusted computer cookie if requested
*
* @param \Scheb\TwoFactorBundle\Security\TwoFactor\AuthenticationContext $context
* @return \Symfony\Component\HttpFoundation\Response|null
*/
public function requestAuthenticationCode(AuthenticationContext $context)
{
$request = $context->getRequest();
$user = $context->getUser();
$context->setUseTrustedOption($this->useTrustedOption($user));
// 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() && $request->get($this->trustedName)) {
$cookie = $this->cookieManager->createTrustedCookie($request, $user);
$response->headers->setCookie($cookie);
}
return $response;
}
return null;
}