diff --git a/src/Entity/User.php b/src/Entity/User.php index 447a323..ba428bc 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -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 diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index b7bead5..570efd5 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -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)));