Skip to content

Commit

Permalink
bug #33239 [Ldap] Make LdapUser implement EquatableInterface (chalasr)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[Ldap] Make LdapUser implement EquatableInterface

| 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        | -

Bugfix because it is required for password migrations https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Ldap/Security/LdapUserProvider.php#L128

Commits
-------

ae25509 [Ldap] Make LdapUser implement EquatableInterface
  • Loading branch information
fabpot committed Aug 19, 2019
2 parents 54b6eb1 + ae25509 commit c098374
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/Symfony/Component/Ldap/Security/LdapUser.php
Expand Up @@ -12,14 +12,15 @@
namespace Symfony\Component\Ldap\Security;

use Symfony\Component\Ldap\Entry;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* @author Robin Chalas <robin.chalas@gmail.com>
*
* @final
*/
class LdapUser implements UserInterface
class LdapUser implements UserInterface, EquatableInterface
{
private $entry;
private $username;
Expand Down Expand Up @@ -88,4 +89,28 @@ public function getExtraFields(): array
{
return $this->extraFields;
}

/**
* {@inheritdoc}
*/
public function isEqualTo(UserInterface $user): bool
{
if (!$user instanceof self) {
return false;
}

if ($this->getPassword() !== $user->getPassword()) {
return false;
}

if ($this->getSalt() !== $user->getSalt()) {
return false;
}

if ($this->getUsername() !== $user->getUsername()) {
return false;
}

return true;
}
}

0 comments on commit c098374

Please sign in to comment.