Skip to content

Commit 22d653f

Browse files
committed
Handle consecutive supports() calls in the RememberMeAuthenticator
1 parent b5c9736 commit 22d653f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Authenticator/RememberMeAuthenticator.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ public function supports(Request $request): ?bool
5656
return false;
5757
}
5858

59+
// if the attribute is set, this is a lazy firewall. The previous
60+
// support call already indicated support, so return null and avoid
61+
// recreating the cookie
62+
if ($request->attributes->has('_remember_me_token')) {
63+
return null;
64+
}
65+
5966
$token = $this->rememberMeServices->autoLogin($request);
6067
if (null === $token) {
6168
return false;

Tests/Authenticator/RememberMeAuthenticatorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public function provideSupportsData()
6060
yield [$this->createMock(TokenInterface::class), null];
6161
}
6262

63+
public function testConsecutiveSupportsCalls()
64+
{
65+
$this->rememberMeServices->expects($this->once())->method('autoLogin')->with($this->request)->willReturn($this->createMock(TokenInterface::class));
66+
67+
$this->assertNull($this->authenticator->supports($this->request));
68+
$this->assertNull($this->authenticator->supports($this->request));
69+
}
70+
6371
public function testAuthenticate()
6472
{
6573
$this->request->attributes->set('_remember_me_token', new RememberMeToken($user = new User('wouter', 'test'), 'main', 'secret'));

0 commit comments

Comments
 (0)