mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
Update UsrAuthprovider and AuthFailure entities
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
@@ -73,6 +74,11 @@ class UsrAuthProvider
|
||||
return $this->usr_id;
|
||||
}
|
||||
|
||||
public function getUser(Application $app)
|
||||
{
|
||||
return \User_Adapter::getInstance($this->usr_id, $app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set provider
|
||||
*
|
||||
|
48
lib/Doctrine/Repositories/AuthFailureRepository.php
Normal file
48
lib/Doctrine/Repositories/AuthFailureRepository.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace 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 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 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();
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
Entities\AuthFailure:
|
||||
type: entity
|
||||
table: AuthFailuress
|
||||
repositoryClass: Repositories\AuthFailureRepository
|
||||
table: AuthFailures
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
|
@@ -5,8 +5,7 @@ Entities\UsrAuthProvider:
|
||||
uniqueConstraints:
|
||||
unique_provider_per_user:
|
||||
columns: [ usr_id, provider ]
|
||||
indexes:
|
||||
provider_distant_id:
|
||||
provider_ids:
|
||||
columns: [ provider, distant_id ]
|
||||
id:
|
||||
id:
|
||||
@@ -18,10 +17,10 @@ Entities\UsrAuthProvider:
|
||||
type: integer
|
||||
provider:
|
||||
type: string
|
||||
length: 64
|
||||
length: 32
|
||||
distant_id:
|
||||
type: string
|
||||
length: 256
|
||||
length: 192
|
||||
updated:
|
||||
type: datetime
|
||||
gedmo:
|
||||
|
Reference in New Issue
Block a user