postgresql/auth: Fix that users cannot login when using PostgreSQL >= version 9.0

fixes #8251
This commit is contained in:
Eric Lippmann 2015-01-19 16:43:19 +01:00
parent d275bc0762
commit 2bd2f32b2e
1 changed files with 10 additions and 3 deletions

View File

@ -87,9 +87,16 @@ class DbUserBackend extends UserBackend
*/
protected function getPasswordHash($username)
{
if ($this->conn->getDbType() === 'pgsql') {
// Since PostgreSQL version 9.0 the default value for bytea_output is 'hex' instead of 'escape'
$stmt = $this->conn->getDbAdapter()->prepare(
'SELECT ENCODE(password_hash, \'escape\') FROM icingaweb_user WHERE name = :name AND active = 1'
);
} else {
$stmt = $this->conn->getDbAdapter()->prepare(
'SELECT password_hash FROM icingaweb_user WHERE name = :name AND active = 1'
);
}
$stmt->execute(array(':name' => $username));
$stmt->bindColumn(1, $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);