bug #33263 [Ldap] Add missing LdapUser::setPassword() (chalasr)

This PR was merged into the 4.4 branch.

Discussion
----------

[Ldap] Add missing LdapUser::setPassword()

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Required for password migrations.

Commits
-------

08dd4f3ae1 [Ldap] Add missing LdapUser::setPassword()
This commit is contained in:
Nicolas Grekas 2019-08-20 23:06:27 +02:00
commit 543e4013d0
2 changed files with 8 additions and 5 deletions

View File

@ -90,6 +90,11 @@ class LdapUser implements UserInterface, EquatableInterface
return $this->extraFields;
}
public function setPassword(string $password)
{
$this->password = $password;
}
/**
* {@inheritdoc}
*/

View File

@ -125,11 +125,9 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa
}
try {
if ($user->isEqualTo($this->loadUserByUsername($user->getUsername()))) {
$user->getEntry()->setAttribute($this->passwordAttribute, [$newEncodedPassword]);
$this->ldap->getEntryManager()->update($user->getEntry());
$user->setPassword($newEncodedPassword);
}
$user->getEntry()->setAttribute($this->passwordAttribute, [$newEncodedPassword]);
$this->ldap->getEntryManager()->update($user->getEntry());
$user->setPassword($newEncodedPassword);
} catch (ExceptionInterface $e) {
// ignore failed password upgrades
}