Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions library/Director/Objects/IcingaHost.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,15 @@ public static function loadWithApiKey($key, Db $db)
$query = $db->getDbAdapter()
->select()
->from('icinga_host')
->where('api_key = ?', $key);
->where('api_key IS NOT NULL')
->query();

$result = self::loadAll($db, $query);
if (count($result) !== 1) {
throw new NotFoundError('Got invalid API key "%s"', $key);
foreach ($query as $row) {
if (hash_equals($row->api_key, $key)) {
return (new static())->setConnection($db)->setDbProperties($row);
}
}

return current($result);
throw new NotFoundError('Got invalid API key "%s"', $key);
}
}
Loading