diff --git a/src/Symfony/Bridge/Doctrine/Security/User/UserLoaderInterface.php b/src/Symfony/Bridge/Doctrine/Security/User/UserLoaderInterface.php index b190eb249967a..551017c313315 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/UserLoaderInterface.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/UserLoaderInterface.php @@ -29,4 +29,10 @@ */ interface UserLoaderInterface { + /** + * @return UserInterface|null + * + * @deprecated since Symfony 5.3, use loadUserByIdentifier() instead + */ + public function loadUserByUsername(string $username); } diff --git a/src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentTokenInterface.php b/src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentTokenInterface.php index 85c5bc385e580..18eea22587b98 100644 --- a/src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentTokenInterface.php +++ b/src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentTokenInterface.php @@ -48,4 +48,11 @@ public function getTokenValue(); * @return \DateTime */ public function getLastUsed(); + + /** + * @return string + * + * @deprecated since Symfony 5.3, use getUserIdentifier() instead + */ + public function getUsername(); } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php b/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php index 047f571ae4a20..82633f92051f3 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php @@ -130,4 +130,11 @@ public function __serialize(): array; * Restores the object state from an array given by __serialize(). */ public function __unserialize(array $data): void; + + /** + * @return string + * + * @deprecated since Symfony 5.3, use getUserIdentifier() instead + */ + public function getUsername(); } diff --git a/src/Symfony/Component/Security/Core/User/UserInterface.php b/src/Symfony/Component/Security/Core/User/UserInterface.php index 6448ab519248d..f30d36e17d4d6 100644 --- a/src/Symfony/Component/Security/Core/User/UserInterface.php +++ b/src/Symfony/Component/Security/Core/User/UserInterface.php @@ -78,4 +78,11 @@ public function getSalt(); * the plain-text password is stored on this object. */ public function eraseCredentials(); + + /** + * @return string + * + * @deprecated since Symfony 5.3, use getUserIdentifier() instead + */ + public function getUsername(); } diff --git a/src/Symfony/Component/Security/Core/User/UserProviderInterface.php b/src/Symfony/Component/Security/Core/User/UserProviderInterface.php index 5ab67836c730f..2444bdfa242d6 100644 --- a/src/Symfony/Component/Security/Core/User/UserProviderInterface.php +++ b/src/Symfony/Component/Security/Core/User/UserProviderInterface.php @@ -57,4 +57,13 @@ public function refreshUser(UserInterface $user); * @return bool */ public function supportsClass(string $class); + + /** + * @return UserInterface + * + * @throws UserNotFoundException + * + * @deprecated since Symfony 5.3, use loadUserByIdentifier() instead + */ + public function loadUserByUsername(string $username); } diff --git a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php index 02f6f0182f503..877e1b62bdb57 100644 --- a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php @@ -211,6 +211,11 @@ public function createUser(TestLoginLinkHandlerUser $user): void $this->users[$user->getUserIdentifier()] = $user; } + public function loadUserByUsername($username): TestLoginLinkHandlerUser + { + return $this->loadUserByIdentifier($username); + } + public function loadUserByIdentifier(string $userIdentifier): TestLoginLinkHandlerUser { if (!isset($this->users[$userIdentifier])) {