[Ldap] Make LdapUser implement EquatableInterface

This commit is contained in:
Robin Chalas 2019-08-19 14:33:50 +02:00
parent 034c06e181
commit ae255095ea
1 changed files with 26 additions and 1 deletions

View File

@ -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;
}
}