From 4c29c960c758a8b6335e02e18f7d4bb5acdba184 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Mon, 17 Jun 2019 15:27:58 +0100 Subject: [PATCH] Added HTTP 401 for failed due to no api key and 201 used when qso created successfully --- application/controllers/Api.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/controllers/Api.php b/application/controllers/Api.php index c04ef585..b5c3ec79 100644 --- a/application/controllers/Api.php +++ b/application/controllers/Api.php @@ -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']]); }