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