Skip to content

Commit 8b7c95b

Browse files
committed
[Security] Pass attributes to nested ChainUserProviders
1 parent af1b894 commit 8b7c95b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Tests/User/ChainUserProviderTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public function testLoadUserByIdentifier()
4949

5050
public function testLoadUserByIdentifierWithAttributes()
5151
{
52+
$provider0 = $this->createMock(ChainUserProvider::class);
53+
$provider0
54+
->expects($this->once())
55+
->method('loadUserByIdentifier')
56+
->with($this->equalTo('foo'), $this->equalTo(['attr' => 5]))
57+
->willThrowException(new UserNotFoundException('not found'))
58+
;
59+
5260
$provider1 = $this->createMock(UserProviderInterface::class);
5361
$provider1
5462
->expects($this->once())
@@ -65,7 +73,7 @@ public function testLoadUserByIdentifierWithAttributes()
6573
->willReturn($account = $this->createMock(UserInterface::class))
6674
;
6775

68-
$provider = new ChainUserProvider([$provider1, $provider2]);
76+
$provider = new ChainUserProvider([$provider0, $provider1, $provider2]);
6977
$this->assertSame($account, $provider->loadUserByIdentifier('foo', ['attr' => 5]));
7078
}
7179

User/ChainUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function loadUserByIdentifier(string $identifier/* , array $attributes =
6464
$attributes = \func_num_args() > 1 ? func_get_arg(1) : [];
6565
foreach ($this->providers as $provider) {
6666
try {
67-
if ($provider instanceof AttributesBasedUserProviderInterface) {
67+
if ($provider instanceof AttributesBasedUserProviderInterface || $provider instanceof self) {
6868
return $provider->loadUserByIdentifier($identifier, $attributes);
6969
}
7070

0 commit comments

Comments
 (0)