fix missing implements in the user entity

This commit is contained in:
Simon Vieille 2022-01-24 22:15:53 +01:00
parent 0ac49a6930
commit 0984edf462
2 changed files with 10 additions and 18 deletions

View file

@ -84,6 +84,14 @@ class User implements PasswordAuthenticatedUserInterface, UserInterface, TwoFact
return $this->id;
}
/**
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return $this->getUsername();
}
public function getEmail(): ?string
{
return $this->email;
@ -96,11 +104,6 @@ class User implements PasswordAuthenticatedUserInterface, UserInterface, TwoFact
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
@ -131,9 +134,6 @@ class User implements PasswordAuthenticatedUserInterface, UserInterface, TwoFact
return $this;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
@ -146,20 +146,11 @@ class User implements PasswordAuthenticatedUserInterface, UserInterface, TwoFact
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here

View file

@ -8,6 +8,7 @@ use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
@ -16,7 +17,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
parent::__construct($registry, User::class);
}
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newEncodedPassword): void
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));