Added HTTP 401 for failed due to no api key and 201 used when qso created successfully

This commit is contained in:
Peter Goodhall
2019-06-17 15:27:58 +01:00
parent 2afa5697c6
commit 4c29c960c7

View File

@@ -346,6 +346,7 @@ 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) {
http_response_code(401);
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
die();
}
@@ -371,8 +372,8 @@ class API extends CI_Controller {
$this->logbook_model->import($record);
};
echo json_encode(['status' => 'success', 'type' => $obj['type'], 'string' => $obj['string']]);
http_response_code(201 );
echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string']]);
}