Skip to content

Commit 69eeab0

Browse files
committed
minor #13791 Update the Snippet with the PasswordUpgraderInterface (zairigimad)
This PR was submitted for the 5.0 branch but it was merged into the 4.4 branch instead. Discussion ---------- Update the Snippet with the PasswordUpgraderInterface <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 864cefb Update the Snippet with the UserUpgraderInterface
2 parents 9453d50 + 864cefb commit 69eeab0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

security/user_provider.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,11 @@ command will generate a nice skeleton to get you started::
356356

357357
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
358358
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
359+
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
359360
use Symfony\Component\Security\Core\User\UserInterface;
360361
use Symfony\Component\Security\Core\User\UserProviderInterface;
361362

362-
class UserProvider implements UserProviderInterface
363+
class UserProvider implements UserProviderInterface, PasswordUpgraderInterface
363364
{
364365
/**
365366
* Symfony calls this method if you use features like switch_user
@@ -412,6 +413,16 @@ command will generate a nice skeleton to get you started::
412413
{
413414
return User::class === $class || is_subclass_of($class, User::class);
414415
}
416+
417+
/**
418+
* Upgrades the encoded password of a user, typically for using a better hash algorithm.
419+
*/
420+
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
421+
{
422+
// TODO: when encoded passwords are in use, this method should:
423+
// 1. persist the new password in the user storage
424+
// 2. update the $user object with $user->setPassword($newEncodedPassword);
425+
}
415426
}
416427

417428
Most of the work is already done! Read the comments in the code and update the

0 commit comments

Comments
 (0)