mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
parent
1ef5d5adaf
commit
c92e1307f6
@ -34,6 +34,7 @@ use Zend_Db_Expr;
|
|||||||
use Icinga\Authentication\UserBackend;
|
use Icinga\Authentication\UserBackend;
|
||||||
use Icinga\Data\Db\Connection;
|
use Icinga\Data\Db\Connection;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
|
use \Zend_Db_Select;
|
||||||
|
|
||||||
class DbUserBackend extends UserBackend
|
class DbUserBackend extends UserBackend
|
||||||
{
|
{
|
||||||
@ -58,10 +59,12 @@ class DbUserBackend extends UserBackend
|
|||||||
*/
|
*/
|
||||||
public function hasUser(User $user)
|
public function hasUser(User $user)
|
||||||
{
|
{
|
||||||
$row = $this->conn->select()->from('account', array(new Zend_Db_Expr(1)))
|
$select = new Zend_Db_Select($this->conn->getConnection());
|
||||||
|
$row = $select->from('account', array(new Zend_Db_Expr(1)))
|
||||||
->where('username = ?', $user->getUsername())
|
->where('username = ?', $user->getUsername())
|
||||||
->fetch();
|
->query()->fetchObject();
|
||||||
return $row !== false ? true : false;
|
|
||||||
|
return ($row !== false) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,6 +74,7 @@ class DbUserBackend extends UserBackend
|
|||||||
* @param string $password
|
* @param string $password
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \Exception If we can not fetch the salt
|
||||||
*/
|
*/
|
||||||
public function authenticate(User $user, $password)
|
public function authenticate(User $user, $password)
|
||||||
{
|
{
|
||||||
@ -81,12 +85,15 @@ class DbUserBackend extends UserBackend
|
|||||||
if ($salt === '') {
|
if ($salt === '') {
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
$row = $this->conn->select()->from('account', array(new Zend_Db_Expr(1)))
|
|
||||||
|
$select = new Zend_Db_Select($this->conn->getConnection());
|
||||||
|
$row = $select->from('account', array(new Zend_Db_Expr(1)))
|
||||||
->where('username = ?', $user->getUsername())
|
->where('username = ?', $user->getUsername())
|
||||||
->where('active = ?', true)
|
->where('active = ?', true)
|
||||||
->where('password = ?', $this->hashPassword($password, $salt))
|
->where('password = ?', $this->hashPassword($password, $salt))
|
||||||
->fetchRow();
|
->query()->fetchObject();
|
||||||
return $row !== false ? true : false;
|
|
||||||
|
return ($row !== false) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,8 +105,9 @@ class DbUserBackend extends UserBackend
|
|||||||
*/
|
*/
|
||||||
private function getSalt($username)
|
private function getSalt($username)
|
||||||
{
|
{
|
||||||
$row = $this->conn->select()->from('account', array('salt'))->where('username = ?', $username)->fetchRow();
|
$select = new Zend_Db_Select($this->conn->getConnection());
|
||||||
return $row !== false ? $row->salt : null;
|
$row = $select->from('account', array('salt'))->where('username = ?', $username)->query()->fetchObject();
|
||||||
|
return ($row !== false) ? $row->salt : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,6 +129,12 @@ class DbUserBackend extends UserBackend
|
|||||||
*/
|
*/
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return $this->conn->select()->from('account', array('count' => 'COUNT(*)'))->fetch()->count();
|
$select = new Zend_Db_Select($this->conn->getConnection());
|
||||||
|
$row = $select->from(
|
||||||
|
'account',
|
||||||
|
array('count' => 'COUNT(*)')
|
||||||
|
)->query()->fetchObject();
|
||||||
|
|
||||||
|
return ($row !== false) ? $row->count : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user