Make it a POST request and report status

This commit is contained in:
zone11
2025-01-04 22:17:50 +01:00
parent 2fc64208df
commit 35c1a93789

View File

@@ -971,12 +971,14 @@ class API extends CI_Controller {
return $latlng;
}
function version($key = '') {
function version() {
// This API endpoint provides the version of Wavelog if the provide key has at least read permissions
$this->load->model('api_model');
$key = $this->input->post('key', TRUE);
header("Content-type: application/json");
if(substr($this->api_model->access($key),0,1) == 'r') {
echo json_encode(['version' => $this->optionslib->get_option('version')]);
echo json_encode(['status' => 'ok', 'version' => $this->optionslib->get_option('version')]);
} else {
http_response_code(401);
echo json_encode(['status' => 'failed', 'reason' => "missing or invalid api key"]);