mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Check server creation for clone server call
This commit is contained in:
parent
1211b22183
commit
e053f4a750
@ -30,7 +30,11 @@ class ApiServersServerActionHandler(BaseApiHandler):
|
||||
return self.finish_json(400, {"status": "error", "error": "NOT_AUTHORIZED"})
|
||||
|
||||
if action == "clone_server":
|
||||
return self._clone_server(server_id, auth_data[4]["user_id"])
|
||||
if self.controller.crafty_perms.can_create_server(auth_data[4]["user_id"]):
|
||||
return self._clone_server(server_id, auth_data[4]["user_id"])
|
||||
return self.finish_json(
|
||||
200, {"status": "error", "error": "SERVER_LIMIT_REACHED"}
|
||||
)
|
||||
if action == "eula":
|
||||
return self._agree_eula(server_id, auth_data[4]["user_id"])
|
||||
|
||||
|
@ -598,26 +598,27 @@
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function send_command(server_id, command) {
|
||||
async function send_command(server_id, command) {
|
||||
/* this getCookie function is in base.html */
|
||||
const token = getCookie("_xsrf");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: `/api/v2/servers/${server_id}/action/${command}`,
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
if (command === "clone_server" && data.status === "ok") {
|
||||
window.location.reload();
|
||||
}
|
||||
/*setTimeout(function () {
|
||||
if (command != 'start_server') {
|
||||
location.reload();
|
||||
}
|
||||
}, 10000);*/
|
||||
}
|
||||
let res = await fetch(`/api/v2/servers/${server_id}/action/${command}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'token': token,
|
||||
},
|
||||
});
|
||||
let responseData = await res.json();
|
||||
if (responseData.status === "ok") {
|
||||
if (command === "clone_server"){
|
||||
window.location.reload()
|
||||
}
|
||||
console.log("Command received successfully")
|
||||
} else {
|
||||
bootbox.alert({
|
||||
title: responseData.status,
|
||||
message: responseData.error
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user