mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Phrasea\Model\Repositories;
|
|
|
|
use Doctrine\ORM\EntityRepository;
|
|
|
|
/**
|
|
* AuthFailureRepository
|
|
*
|
|
* This class was generated by the Doctrine ORM. Add your own custom
|
|
* repository methods below.
|
|
*/
|
|
class AuthFailureRepository extends EntityRepository
|
|
{
|
|
public function findOldFailures($limit = '-2 months')
|
|
{
|
|
$date = new \DateTime($limit);
|
|
|
|
$dql = 'SELECT f
|
|
FROM Alchemy\Phrasea\Model\Entities\AuthFailure f
|
|
WHERE f.created < :date';
|
|
|
|
$params = array('date' => $date->format('Y-m-d h:i:s'));
|
|
|
|
$query = $this->_em->createQuery($dql);
|
|
$query->setParameters($params);
|
|
|
|
return $query->getResult();
|
|
}
|
|
|
|
public function findLockedFailuresMatching($username, $ip)
|
|
{
|
|
$dql = 'SELECT f
|
|
FROM Alchemy\Phrasea\Model\Entities\AuthFailure f
|
|
WHERE (f.username = :username OR f.ip = :ip)
|
|
AND f.locked = true';
|
|
|
|
$params = array(
|
|
'username' => $username,
|
|
'ip' => $ip,
|
|
);
|
|
|
|
$query = $this->_em->createQuery($dql);
|
|
$query->setParameters($params);
|
|
|
|
return $query->getResult();
|
|
}
|
|
}
|