Skip to content

Commit 6cf15c0

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Update the Snippet with the UserUpgraderInterface
2 parents 2de840e + 69eeab0 commit 6cf15c0

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
@@ -360,10 +360,11 @@ command will generate a nice skeleton to get you started::
360360

361361
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
362362
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
363+
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
363364
use Symfony\Component\Security\Core\User\UserInterface;
364365
use Symfony\Component\Security\Core\User\UserProviderInterface;
365366

366-
class UserProvider implements UserProviderInterface
367+
class UserProvider implements UserProviderInterface, PasswordUpgraderInterface
367368
{
368369
/**
369370
* Symfony calls this method if you use features like switch_user
@@ -416,6 +417,16 @@ command will generate a nice skeleton to get you started::
416417
{
417418
return User::class === $class || is_subclass_of($class, User::class);
418419
}
420+
421+
/**
422+
* Upgrades the encoded password of a user, typically for using a better hash algorithm.
423+
*/
424+
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
425+
{
426+
// TODO: when encoded passwords are in use, this method should:
427+
// 1. persist the new password in the user storage
428+
// 2. update the $user object with $user->setPassword($newEncodedPassword);
429+
}
419430
}
420431

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

0 commit comments

Comments
 (0)