Skip to content

Commit df3612c

Browse files
authored
Check more specific if login was successful (#99)
1 parent e19887e commit df3612c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Service/ScannerService.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,11 @@ private function getAdmin(string $user, string $password, ScannerServiceCallback
228228
$response = $this->client->post($this->baseUrl . 'admin-auth/', [
229229
'auth' => [$user, $password],
230230
]);
231-
$callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200);
231+
$body = (string) $response->getBody();
232+
$callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200 && $body === 'Authorized');
232233
return;
233234
} catch (GuzzleException $e) {
234-
if ($e->getCode() === 401) {
235+
if ($e->getCode() === 401 || $e->getCode() === 403) {
235236
$callback->onScanAdminResult($user, $password, false);
236237
return;
237238
}
@@ -241,7 +242,8 @@ private function getAdmin(string $user, string $password, ScannerServiceCallback
241242
$response = $this->client->get($this->baseUrl . 'admin/', [
242243
'auth' => [$user, $password],
243244
]);
244-
$callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200);
245+
$body = (string) $response->getBody();
246+
$callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200 && str_contains($body, 'Plugin manager'));
245247
return;
246248
} catch (GuzzleException) {
247249
$callback->onScanAdminResult($user, $password, false);

0 commit comments

Comments
 (0)