MAPG-185 add getter for expired users and password resetters

This commit is contained in:
Bence Pőcze 2020-07-05 16:37:37 +02:00
parent 776561a41c
commit b254603fb1
Signed by: bence
GPG Key ID: AA52B11A3269D1C1
2 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,7 @@
<?php namespace MapGuesser\Repository;
use DateTime;
use Generator;
use MapGuesser\Database\Query\Select;
use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\UserPasswordResetter;
@ -34,4 +36,12 @@ class UserPasswordResetterRepository
return $this->pdm->selectFromDb($select, UserPasswordResetter::class);
}
public function getAllExpired(): Generator
{
$select = new Select(\Container::$dbConnection);
$select->where('expires', '<', (new DateTime())->format('Y-m-d H:i:s'));
yield from $this->pdm->selectMultipleFromDb($select, UserPasswordResetter::class);
}
}

View File

@ -1,5 +1,7 @@
<?php namespace MapGuesser\Repository;
use DateTime;
use Generator;
use MapGuesser\Database\Query\Select;
use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\PersistentDataManager;
@ -33,4 +35,13 @@ class UserRepository
return $this->pdm->selectFromDb($select, User::class);
}
public function getAllInactiveExpired(): Generator
{
$select = new Select(\Container::$dbConnection);
$select->where('active', '=', false);
$select->where('created', '<', (new DateTime('-1 day'))->format('Y-m-d H:i:s'));
yield from $this->pdm->selectMultipleFromDb($select, User::class);
}
}