pi hole
All checks were successful
Deploy / deploy-staging (push) Successful in 5s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-27 00:41:37 +02:00
parent e7a1878c72
commit 463b2cf5e1
6 changed files with 40 additions and 22 deletions

View File

@@ -91,8 +91,8 @@ $httpRequest = function (string $method, string $url, array $headers, ?string $b
};
$v5Request = function (array $instance, array $params) use ($normalizeApiPath, $httpRequest): array {
if (!empty($instance['token']) && !isset($params['auth'])) {
$params['auth'] = $instance['token'];
if (!empty($instance['password']) && !isset($params['auth'])) {
$params['auth'] = $instance['password'];
}
$url = $normalizeApiPath((string)$instance['url'], (string)$instance['api_path']);
@@ -116,7 +116,7 @@ $v6Auth = function (array $instance) use ($httpRequest): array {
$timeout = 8;
}
$verify = !empty($instance['verify_tls']);
$payload = ['password' => (string)($instance['token'] ?? '')];
$payload = ['password' => (string)($instance['password'] ?? '')];
$body = json_encode($payload, JSON_UNESCAPED_UNICODE);
$res = $httpRequest('POST', $url, ['Accept: application/json', 'Content-Type: application/json'], $body, $verify, $timeout);
if (!$res['ok']) {
@@ -159,7 +159,7 @@ $v6Request = function (array $instance, string $path, string $method, array $pay
$detectApi = function (array $instance) use ($v6Auth, $v6Request, $v5Request): array {
$sid = '';
$authRes = null;
if (!empty($instance['token'])) {
if (!empty($instance['password'])) {
$authRes = $v6Auth($instance);
if (($authRes['ok'] ?? false) && !empty($authRes['sid'])) {
$sid = (string)$authRes['sid'];
@@ -621,7 +621,7 @@ if ($action === 'test') {
$message = 'Host nicht erreichbar oder kein HTTP-Response.';
} elseif ($httpCode === 401 || $httpCode === 403) {
$status = 'auth';
$message = 'API Passwort falsch oder nicht berechtigt.';
$message = 'Passwort oder App-Passwort falsch oder nicht berechtigt.';
} elseif ($error === 'invalid_json') {
$status = 'invalid';
$message = 'API antwortet nicht mit JSON. URL pruefen.';
@@ -659,7 +659,7 @@ if ($action === 'test') {
$message = 'Host nicht erreichbar oder kein HTTP-Response.';
} elseif ($httpCode === 401 || $httpCode === 403) {
$status = 'auth';
$message = 'API Token/Passwort falsch oder nicht berechtigt.';
$message = 'Passwort oder Legacy-API-Token falsch oder nicht berechtigt.';
} elseif ($error === 'invalid_json') {
$status = 'invalid';
$message = 'API antwortet nicht mit JSON. URL oder API-Pfad pruefen.';