Skip to content

Commit 5a9a351

Browse files
minor symfony#60009 Improve documentation of PasswordUpgraderInterface (stof)
This PR was squashed before being merged into the 7.3 branch. Discussion ---------- Improve documentation of PasswordUpgraderInterface | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | n/a | License | MIT Implementations of PasswordUpgraderInterface can be called with a user instance that they don't support and are expected to handle it gracefully. Handling it gracefully can be done either by being silent or by throwing an UnsupportedUserException. This is a follow-up of symfony#51283 to document that throwing UnsupportedUserException is actually fine for implementations as the way to handle unsupported users, as shown by the implementation of the ChainUserProvider: https://github.com/symfony/symfony/blob/07e020abdd1ab820ca3c2ead8dfda75ea6e84eae/src/Symfony/Component/Security/Core/User/ChainUserProvider.php#L107-L113 Commits ------- 0784f98 Improve documentation of PasswordUpgraderInterface
2 parents 07e020a + 0784f98 commit 5a9a351

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/Security/Core/User/PasswordUpgraderInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Security\Core\User;
1313

14+
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
15+
1416
/**
1517
* @author Nicolas Grekas <[email protected]>
1618
*/
@@ -22,6 +24,8 @@ interface PasswordUpgraderInterface
2224
* This method should persist the new password in the user storage and update the $user object accordingly.
2325
* Because you don't want your users not being able to log in, this method should be opportunistic:
2426
* it's fine if it does nothing or if it fails without throwing any exception.
27+
*
28+
* @throws UnsupportedUserException if the implementation does not support that user
2529
*/
2630
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void;
2731
}

0 commit comments

Comments
 (0)