Skip to content

Commit

Permalink
[Ldap] fix refreshUser() ignoring extra_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
arkste authored and chalasr committed Jun 10, 2020
1 parent 5b719d1 commit cb8f129
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Security/LdapUserProvider.php
Expand Up @@ -108,7 +108,7 @@ public function refreshUser(UserInterface $user)
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
}

return new LdapUser($user->getEntry(), $user->getUsername(), $user->getPassword(), $user->getRoles());
return new LdapUser($user->getEntry(), $user->getUsername(), $user->getPassword(), $user->getRoles(), $user->getExtraFields());
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Ldap/Tests/Security/LdapUserProviderTest.php
Expand Up @@ -330,4 +330,14 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword', ['email']);
$this->assertInstanceOf(LdapUser::class, $provider->loadUserByUsername('foo'));
}

public function testRefreshUserShouldReturnUserWithSameProperties()
{
$ldap = $this->createMock(LdapInterface::class);
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword', ['email']);

$user = new LdapUser(new Entry('foo'), 'foo', 'bar', ['ROLE_DUMMY'], ['email' => 'foo@symfony.com']);

$this->assertEquals($user, $provider->refreshUser($user));
}
}

0 comments on commit cb8f129

Please sign in to comment.