From ae255095ea8cb01f45e955d1c697db6edb5c7177 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Mon, 19 Aug 2019 14:33:50 +0200 Subject: [PATCH] [Ldap] Make LdapUser implement EquatableInterface --- .../Component/Ldap/Security/LdapUser.php | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Ldap/Security/LdapUser.php b/src/Symfony/Component/Ldap/Security/LdapUser.php index 42c6dbcdf8..ce20f2fd52 100644 --- a/src/Symfony/Component/Ldap/Security/LdapUser.php +++ b/src/Symfony/Component/Ldap/Security/LdapUser.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Ldap\Security; use Symfony\Component\Ldap\Entry; +use Symfony\Component\Security\Core\User\EquatableInterface; use Symfony\Component\Security\Core\User\UserInterface; /** @@ -19,7 +20,7 @@ use Symfony\Component\Security\Core\User\UserInterface; * * @final */ -class LdapUser implements UserInterface +class LdapUser implements UserInterface, EquatableInterface { private $entry; private $username; @@ -88,4 +89,28 @@ class LdapUser implements UserInterface { 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; + } }