Check if request has trusted cookie and if it's valid.
public isTrustedComputer ( |
||
$request | ||
$user | mixed | |
Результат | boolean |
/** * @test */ public function isTrustedComputer_validTrustedCode_returnTrue() { $user = $this->createMock('Scheb\\TwoFactorBundle\\Model\\TrustedComputerInterface'); $request = $this->createRequest('trustedCode1;trustedCode2'); //Stub the TrustedComputerManager object $this->trustedComputerManager->expects($this->any())->method('isTrustedComputer')->willReturn(true); $returnValue = $this->cookieManager->isTrustedComputer($request, $user); $this->assertTrue($returnValue); }
/** * @test */ public function isTrustedComputer_validTrustedCode_returnTrue() { $user = $this->getMock("Scheb\\TwoFactorBundle\\Model\\TrustedComputerInterface"); $request = $this->createRequest("trustedCode1;trustedCode2"); //Stub the User object $user->expects($this->any())->method("isTrustedComputer")->will($this->returnValue(true)); $returnValue = $this->cookieManager->isTrustedComputer($request, $user); $this->assertTrue($returnValue); }
/** * Check if user is on a trusted computer, otherwise call TwoFactorProviderRegistry. * * @param AuthenticationContextInterface $context */ public function beginAuthentication(AuthenticationContextInterface $context) { $request = $context->getRequest(); $user = $context->getUser(); $context->setUseTrustedOption($this->useTrustedOption); // Skip two-factor authentication on trusted computers if ($context->useTrustedOption() && $this->cookieManager->isTrustedComputer($request, $user)) { return; } $this->authHandler->beginAuthentication($context); }