8000 Fix refresh method of LdapUserProvider · symfony/symfony@301500a · GitHub
[go: up one dir, main page]

Skip to content

Commit 301500a

Browse files
committed
Fix refresh method of LdapUserProvider
1 parent b681e93 commit 301500a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Symfony/Component/Ldap/Security/LdapUserProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Ldap\Security;
1313

14+
use Doctrine\Common\Persistence\ManagerRegistry;
1415
use Symfony\Component\Ldap\Entry;
1516
use Symfony\Component\Ldap\Exception\ConnectionException;
1617
use Symfony\Component\Ldap\Exception\ExceptionInterface;
@@ -31,6 +32,7 @@
3132
*/
3233
class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterface
3334
{
35+
private $managerRegistry;
3436
private $ldap;
3537
private $baseDn;
3638
private $searchDn;
@@ -41,7 +43,7 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa
4143
private $passwordAttribute;
4244
private $extraFields;
4345

44-
public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = [], string $uidKey = null, string $filter = null, string $passwordAttribute = null, array $extraFields = [])
46+
public function __construct(ManagerRegistry $managerRegistry, LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = [], string $uidKey = null, string $filter = null, string $passwordAttribute = null, array $extraFields = [])
4547
{
4648
if (null === $uidKey) {
4749
$uidKey = 'sAMAccountName';
@@ -51,6 +53,7 @@ public function __construct(LdapInterface $ldap, string $baseDn, string $searchD
5153
$filter = '({uid_key}={username})';
5254
}
5355

56+
$this->managerRegistry = $managerRegistry;
5457
$this->ldap = $ldap;
5558
$this->baseDn = $baseDn;
5659
$this->searchDn = $searchDn;
@@ -108,7 +111,7 @@ public function refreshUser(UserInterface $user)
108111
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
109112
}
110113

111-
return new LdapUser($user->getEntry(), $user->getUsername(), $user->getPassword(), $user->getRoles());
114+
return $this->managerRegistry->getRepository(\get_class($user))->findOneBy(['username' => $user->getUsername()]);
112115
}
113116

114117
/**

0 commit comments

Comments
 (0)
0