Merge pull request #2329 from int2001/api_debug

Added 401 in case of missing key to api/radio for easier debugging
This commit is contained in:
Peter Goodhall
2023-07-26 13:35:05 +01:00
committed by GitHub

View File

@@ -635,8 +635,9 @@ class API extends CI_Controller {
$obj = json_decode(file_get_contents("php://input"), true);
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
die();
http_response_code(401);
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
die();
}
$this->api_model->update_last_used($obj['key']);