Skip to content

Commit 622c414

Browse files
Add missing check for basic auth
1 parent d4f16b2 commit 622c414

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

application/libraries/Api.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ public function auth(): void
7777

7878
$password = $_SERVER['PHP_AUTH_PW'] ?? null;
7979

80+
if (empty($username) || empty($password)) {
81+
throw new RuntimeException('Missing required credentials', 401);
82+
}
83+
8084
$user_data = $this->CI->accounts->check_login($username, $password);
8185

8286
if (empty($user_data['role_slug']) || $user_data['role_slug'] !== DB_SLUG_ADMIN) {
83-
throw new RuntimeException(
84-
'The provided credentials do not match any admin user!',
85-
401,
86-
'Unauthorized',
87-
);
87+
throw new RuntimeException('The provided credentials do not match any admin user', 401);
8888
}
8989
} catch (Throwable) {
9090
$this->request_authentication();

0 commit comments

Comments
 (0)