From b4892ff224298fc5b9b5745e9cdceb7cef82a2b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Mon, 21 Jul 2025 22:03:05 +0200 Subject: [PATCH] Check more specific if login was successful --- src/Service/ScannerService.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Service/ScannerService.php b/src/Service/ScannerService.php index 6d32807..3635ef3 100644 --- a/src/Service/ScannerService.php +++ b/src/Service/ScannerService.php @@ -228,10 +228,11 @@ private function getAdmin(string $user, string $password, ScannerServiceCallback $response = $this->client->post($this->baseUrl . 'admin-auth/', [ 'auth' => [$user, $password], ]); - $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200); + $body = (string) $response->getBody(); + $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200 && $body === 'Authorized'); return; } catch (GuzzleException $e) { - if ($e->getCode() === 401) { + if ($e->getCode() === 401 || $e->getCode() === 403) { $callback->onScanAdminResult($user, $password, false); return; } @@ -241,7 +242,8 @@ private function getAdmin(string $user, string $password, ScannerServiceCallback $response = $this->client->get($this->baseUrl . 'admin/', [ 'auth' => [$user, $password], ]); - $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200); + $body = (string) $response->getBody(); + $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200 && str_contains($body, 'Plugin manager')); return; } catch (GuzzleException) { $callback->onScanAdminResult($user, $password, false);