Handle consecutive supports() calls in the RememberMeAuthenticator
This commit is contained in:
parent
c453c3dbd5
commit
e0d1867b54
@ -56,6 +56,13 @@ class RememberMeAuthenticator implements InteractiveAuthenticatorInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
// if the attribute is set, this is a lazy firewall. The previous
|
||||
// support call already indicated support, so return null and avoid
|
||||
// recreating the cookie
|
||||
if ($request->attributes->has('_remember_me_token')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$token = $this->rememberMeServices->autoLogin($request);
|
||||
if (null === $token) {
|
||||
return false;
|
||||
|
@ -60,6 +60,14 @@ class RememberMeAuthenticatorTest extends TestCase
|
||||
yield [$this->createMock(TokenInterface::class), null];
|
||||
}
|
||||
|
||||
public function testConsecutiveSupportsCalls()
|
||||
{
|
||||
$this->rememberMeServices->expects($this->once())->method('autoLogin')->with($this->request)->willReturn($this->createMock(TokenInterface::class));
|
||||
|
||||
$this->assertNull($this->authenticator->supports($this->request));
|
||||
$this->assertNull($this->authenticator->supports($this->request));
|
||||
}
|
||||
|
||||
public function testAuthenticate()
|
||||
{
|
||||
$this->request->attributes->set('_remember_me_token', new RememberMeToken($user = new User('wouter', 'test'), 'main', 'secret'));
|
||||
|
Reference in New Issue
Block a user