Private
Public Access
1
0

chg: usr: add forgot password functionality #4

This commit is contained in:
2026-04-12 08:10:36 +02:00
parent c0dcc2896a
commit e2b227ed7a
8 changed files with 512 additions and 69 deletions

View File

@@ -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');