We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9d2251f commit c08705dCopy full SHA for c08705d
library/Director/Objects/IcingaHost.php
@@ -585,13 +585,15 @@ public static function loadWithApiKey($key, Db $db)
585
$query = $db->getDbAdapter()
586
->select()
587
->from('icinga_host')
588
- ->where('api_key = ?', $key);
+ ->where('api_key IS NOT NULL')
589
+ ->query();
590
- $result = self::loadAll($db, $query);
591
- if (count($result) !== 1) {
592
- throw new NotFoundError('Got invalid API key "%s"', $key);
+ foreach ($query as $row) {
+ if (hash_equals($row->api_key, $key)) {
593
+ return (new static())->setConnection($db)->setDbProperties($row);
594
+ }
595
}
596
- return current($result);
597
+ throw new NotFoundError('Got invalid API key "%s"', $key);
598
599
0 commit comments