fix LDAP hydration with multi-value email field (#862)
This commit is contained in:
committed by
Kevin Papst
parent
bdd05a275d
commit
bb8572a364
@@ -63,6 +63,10 @@ class LdapUserHydrator
|
|||||||
|
|
||||||
$this->hydrateUserWithAttributesMap($user, $ldapEntry, $attributeMap);
|
$this->hydrateUserWithAttributesMap($user, $ldapEntry, $attributeMap);
|
||||||
|
|
||||||
|
if (is_array($user->getEmail())) {
|
||||||
|
$user->setEmail($user->getEmail()[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (null === $user->getEmail()) {
|
if (null === $user->getEmail()) {
|
||||||
$user->setEmail($user->getUsername());
|
$user->setEmail($user->getUsername());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class LdapUserHydratorTest extends TestCase
|
|||||||
'usernameAttribute' => 'foo',
|
'usernameAttribute' => 'foo',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
['ldap_attr' => 'uid', 'user_method' => 'setUsername'],
|
['ldap_attr' => 'uid', 'user_method' => 'setUsername'],
|
||||||
|
['ldap_attr' => 'email', 'user_method' => 'setEmail'],
|
||||||
['ldap_attr' => 'foo', 'user_method' => 'setAlias'],
|
['ldap_attr' => 'foo', 'user_method' => 'setAlias'],
|
||||||
['ldap_attr' => 'bar', 'user_method' => 'setTitle'],
|
['ldap_attr' => 'bar', 'user_method' => 'setTitle'],
|
||||||
['ldap_attr' => 'xxxxxxxx', 'user_method' => 'setAvatar'],
|
['ldap_attr' => 'xxxxxxxx', 'user_method' => 'setAvatar'],
|
||||||
@@ -103,6 +104,7 @@ class LdapUserHydratorTest extends TestCase
|
|||||||
|
|
||||||
$ldapEntry = [
|
$ldapEntry = [
|
||||||
'uid' => ['Karl-Heinz'],
|
'uid' => ['Karl-Heinz'],
|
||||||
|
'email' => [['karl-heinz@example.com', 'foo@example.com', 'bar@example.com']],
|
||||||
'blub' => ['dfsdfsdf'],
|
'blub' => ['dfsdfsdf'],
|
||||||
'foo' => ['bar'],
|
'foo' => ['bar'],
|
||||||
'bar' => ['foo'],
|
'bar' => ['foo'],
|
||||||
@@ -119,7 +121,7 @@ class LdapUserHydratorTest extends TestCase
|
|||||||
self::assertEquals('bar', $user->getAlias());
|
self::assertEquals('bar', $user->getAlias());
|
||||||
self::assertEquals('foo', $user->getTitle());
|
self::assertEquals('foo', $user->getTitle());
|
||||||
self::assertEquals('https://www.example.com', $user->getAvatar());
|
self::assertEquals('https://www.example.com', $user->getAvatar());
|
||||||
self::assertEquals('Karl-Heinz', $user->getEmail());
|
self::assertEquals('karl-heinz@example.com', $user->getEmail());
|
||||||
|
|
||||||
// make sure that the password was resetted in hydrate
|
// make sure that the password was resetted in hydrate
|
||||||
$pwdCheck = clone $user;
|
$pwdCheck = clone $user;
|
||||||
|
|||||||
Reference in New Issue
Block a user