Skip to content

Commit c70241e

Browse files
committed
bug #37177 [Ldap] fix refreshUser() ignoring extra_fields (arkste)
This PR was squashed before being merged into the 4.4 branch (closes #37177). Discussion ---------- [Ldap] fix refreshUser() ignoring extra_fields | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? |no | Tickets | - | License | MIT | Doc PR | - While #31532 introduced `extra_fields` in general, #32824 later added `LdapUser` & `LdapUserProvider` and ignored `extra_fields` on `refreshUser()`. This PR fixes `refreshUser()` and adds a test which makes sure, that the refreshed ldap user doesn't lose its default values. Commits ------- cb8f129 [Ldap] fix refreshUser() ignoring extra_fields
2 parents 5edbf0b + cb8f129 commit c70241e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function refreshUser(UserInterface $user)
108108
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
109109
}
110110

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

114114
/**

src/Symfony/Component/Ldap/Tests/Security/LdapUserProviderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,14 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
330330
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword', ['email']);
331331
$this->assertInstanceOf(LdapUser::class, $provider->loadUserByUsername('foo'));
332332
}
333+
334+
public function testRefreshUserShouldReturnUserWithSameProperties()
335+
{
336+
$ldap = $this->createMock(LdapInterface::class);
337+
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword', ['email']);
338+
339+
$user = new LdapUser(new Entry('foo'), 'foo', 'bar', ['ROLE_DUMMY'], ['email' => 'foo@symfony.com']);
340+
341+
$this->assertEquals($user, $provider->refreshUser($user));
342+
}
333343
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy