Private
Public Access
new: dev: hardening the registration process with removing the not activated registrations #14
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\User;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
@@ -87,6 +88,34 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
||||
}
|
||||
}
|
||||
|
||||
public function countExpiredPendingUsers(DateTimeInterface $now): int
|
||||
{
|
||||
$qb = $this->createQueryBuilder('u');
|
||||
|
||||
return (int) $qb
|
||||
->select($qb->expr()->count('u.id'))
|
||||
->where($qb->expr()->eq('u.isVerified', ':isVerified'))
|
||||
->andWhere($qb->expr()->lte('u.verificationTokenExpiresAt', ':now'))
|
||||
->setParameter('isVerified', false)
|
||||
->setParameter('now', $now)
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function deleteExpiredPendingUsers(DateTimeInterface $now): int
|
||||
{
|
||||
$qb = $this->createQueryBuilder('u');
|
||||
|
||||
return $qb
|
||||
->delete()
|
||||
->where($qb->expr()->eq('u.isVerified', ':isVerified'))
|
||||
->andWhere($qb->expr()->lte('u.verificationTokenExpiresAt', ':now'))
|
||||
->setParameter('isVerified', false)
|
||||
->setParameter('now', $now)
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
|
||||
Reference in New Issue
Block a user