chg: usr: add forgot password functionality #4
This commit is contained in:
@@ -39,6 +39,38 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
public function findOneByEmail(string $email): ?User
|
||||
{
|
||||
$qb = $this->createQueryBuilder('u');
|
||||
|
||||
try {
|
||||
return $qb
|
||||
->where($qb->expr()->eq('u.email', ':email'))
|
||||
->setParameter('email', $email)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
} catch (NonUniqueResultException $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
throw new RuntimeException("Multiple users found with the same email: $email", 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function findOneByResetToken(string $token): ?User
|
||||
{
|
||||
$qb = $this->createQueryBuilder('u');
|
||||
|
||||
try {
|
||||
return $qb
|
||||
->where($qb->expr()->eq('u.resetToken', ':token'))
|
||||
->setParameter('token', $token)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
} catch (NonUniqueResultException $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
throw new RuntimeException("Multiple users found with the same reset token", 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function findOneByUsername(string $username): ?User
|
||||
{
|
||||
$qb = $this->createQueryBuilder('u');
|
||||
|
||||
Reference in New Issue
Block a user