mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Upgrade password when a better method is available.
This commit is contained in:
parent
6a0d027675
commit
05870caf85
1 changed files with 14 additions and 1 deletions
|
@ -28,6 +28,8 @@ use Doctrine\ORM\EntityRepository;
|
|||
use Doctrine\ORM\Mapping;
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
/**
|
||||
* @method User|null find($id, $lockMode = null, $lockVersion = null)
|
||||
|
@ -35,7 +37,7 @@ use Symfony\Bridge\Doctrine\RegistryInterface;
|
|||
* @method User[] findAll()
|
||||
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class UserRepository extends EntityRepository
|
||||
class UserRepository extends EntityRepository implements PasswordUpgraderInterface
|
||||
{
|
||||
protected $anonymous_user;
|
||||
|
||||
|
@ -80,4 +82,15 @@ class UserRepository extends EntityRepository
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$user->setPassword($newEncodedPassword);
|
||||
$this->getEntityManager()->flush($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue