1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-01-08 04:05:03 +02:00

[API] Catch more cases where no api route exists

This commit is contained in:
ntimo 2019-10-03 20:52:09 +02:00
parent b9c244b746
commit 2da55296b5
No known key found for this signature in database
GPG Key ID: 3AF3627FB0440D55

View File

@ -206,6 +206,14 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
case "tls-policy-map": case "tls-policy-map":
process_add_return(tls_policy_maps('add', $attr)); process_add_return(tls_policy_maps('add', $attr));
break; break;
default:
http_response_code(404);
echo json_encode(array(
'type' => 'error',
'msg' => 'route not found'
));
unset($_POST);
die();
} }
break; break;
case "get": case "get":
@ -1047,8 +1055,12 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
} }
break; break;
default: default:
echo '{}'; http_response_code(404);
break; echo json_encode(array(
'type' => 'error',
'msg' => 'route not found'
));
die();
} }
break; break;
case "delete": case "delete":
@ -1164,6 +1176,14 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
case "rlhash": case "rlhash":
echo ratelimit('delete', null, implode($items)); echo ratelimit('delete', null, implode($items));
break; break;
default:
http_response_code(404);
echo json_encode(array(
'type' => 'error',
'msg' => 'route not found'
));
unset($_POST);
die();
} }
break; break;
case "edit": case "edit":
@ -1309,10 +1329,18 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
process_edit_return(edit_user_account($attr)); process_edit_return(edit_user_account($attr));
} }
break; break;
default:
http_response_code(404);
echo json_encode(array(
'type' => 'error',
'msg' => 'route not found'
));
unset($_POST);
die();
} }
break; break;
// return no route found if no case is matched // return no route found if no case is matched
default; default:
http_response_code(404); http_response_code(404);
echo json_encode(array( echo json_encode(array(
'type' => 'error', 'type' => 'error',