Merge branch 'bugfix/audit-server-id' into 'dev'

Server ID Audit Log

See merge request crafty-controller/crafty-4!700
This commit is contained in:
Iain Powrie 2024-01-28 23:59:28 +00:00
commit d123bed1f8
3 changed files with 18 additions and 10 deletions

View File

@ -11,6 +11,7 @@
- Fix indent on public status check box ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/691))
- Fix unicode chars in terminal & logs w/ textiowrapper ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/689))
- Provide feedback on file delete failure ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/699))
- Fix bug where audit log would show 0 for any stdin sent to the server ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/700))
### Tweaks
- Refactor Forge server initialisation flow for newer versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/687))
- Remove scroll bars from player management ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/693))

View File

@ -39,7 +39,7 @@ class ApiServersServerStdinHandler(BaseApiHandler):
self.controller.management.add_to_audit_log(
auth_data[4]["user_id"],
f"Sent command ({decoded}) to terminal",
server_id=0,
server_id=server_id,
source_ip=self.get_remote_ip(),
)
if svr.send_command(self.request.body.decode("utf-8")):

View File

@ -164,7 +164,7 @@
const serverId = new URLSearchParams(document.location.search).get('id')
function send_command(serverId, command) {
async function send_command(serverId, command) {
if (command == 'start_server') {
startBtn.setAttribute('disabled', 'disabled');
restartBtn.removeAttribute('disabled');
@ -178,16 +178,23 @@
//<!-- this getCookie function is in base.html-->
const token = getCookie("_xsrf");
$.ajax({
type: "POST",
headers: { 'X-XSRFToken': token },
url: `/api/v2/servers/${serverId}/action/${command}`,
success: function (data) {
console.log("got response:");
console.log(data);
}
let res = await fetch(`/api/v2/servers/${serverId}/action/${command}`, {
method: 'POST',
headers: {
'token': token,
},
});
let responseData = await res.json();
if (responseData.status === "ok") {
console.log("Command received successfully")
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
});
}
}
if (webSocket) {
webSocket.on('update_button_status', function (updateButton) {
if (updateButton.isUpdating) {