Prevent 500s when trying to access api with key=null

This commit is contained in:
int2001
2026-01-04 15:48:44 +00:00
parent 99c813bc7b
commit f00ba98865
2 changed files with 9 additions and 9 deletions

View File

@@ -204,9 +204,9 @@ class API extends CI_Controller {
}
}
function check_auth($key) {
function check_auth($key = '') {
$this->load->model('api_model');
if($this->api_model->access($key) == "No Key Found" || $this->api_model->access($key) == "Key Disabled") {
if($this->api_model->access($key ?? '') == "No Key Found" || $this->api_model->access($key ?? '') == "Key Disabled") {
// set the content type as json
header("Content-type: application/json");
@@ -222,7 +222,7 @@ class API extends CI_Controller {
// set the http response code to 200
http_response_code(200);
// return the json
echo json_encode(['status' => 'valid', 'rights' => $this->api_model->access($key)]);
echo json_encode(['status' => 'valid', 'rights' => $this->api_model->access($key ?? '')]);
}
}