From e10d8b9ca254aabf566072846e0c13f135a38b20 Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 5 Jan 2025 01:07:17 +0100 Subject: [PATCH 1/2] properly handle forward values (can be string or boolean, even though frontend always uses strings :shrug:) --- rcongui/src/pages/settings/autosettings/index.jsx | 4 ++-- rconweb/api/auto_settings.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rcongui/src/pages/settings/autosettings/index.jsx b/rcongui/src/pages/settings/autosettings/index.jsx index e0cc92e64..fe333217f 100644 --- a/rcongui/src/pages/settings/autosettings/index.jsx +++ b/rcongui/src/pages/settings/autosettings/index.jsx @@ -76,11 +76,11 @@ const Autosettings = () => { const submit = useSubmit(); const theme = useTheme(); - const handleApplyClick = (intent) => (e) => { + const handleApplyClick = (intent) => () => { setSubmitting(true); const formData = new FormData(); formData.append("intent", intent); - formData.append("forward", intent === INTENT.APPLY_ALL); + formData.append("forward", intent === INTENT.APPLY_ALL ? "true" : "false"); formData.append("settings", editorContent); submit(formData, {method: "post"}); }; diff --git a/rconweb/api/auto_settings.py b/rconweb/api/auto_settings.py index 412d2bf55..44936bed2 100644 --- a/rconweb/api/auto_settings.py +++ b/rconweb/api/auto_settings.py @@ -70,6 +70,12 @@ def set_auto_settings(request): return api_response(error="Invalid server number", failed=True, status_code=400) do_restart_service = data.get("restart_service", True) do_forward = data.get("forward", False) + if do_forward == "false": + do_forward = False + if do_forward == "true": + do_forward = True + if not isinstance(do_forward, bool): + return api_response(error="forward needs to be a boolean value or empty", failed=True, status_code=400) settings = data.get("settings") if not settings: From 00cbe2a1263053e466f30e28f0cce60473b37fe1 Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 5 Jan 2025 01:16:00 +0100 Subject: [PATCH 2/2] also handle 1 and 0 --- rconweb/api/auto_settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rconweb/api/auto_settings.py b/rconweb/api/auto_settings.py index 44936bed2..f27cc4c77 100644 --- a/rconweb/api/auto_settings.py +++ b/rconweb/api/auto_settings.py @@ -70,9 +70,9 @@ def set_auto_settings(request): return api_response(error="Invalid server number", failed=True, status_code=400) do_restart_service = data.get("restart_service", True) do_forward = data.get("forward", False) - if do_forward == "false": + if do_forward == "false" or do_forward == "0": do_forward = False - if do_forward == "true": + if do_forward == "true" or do_forward == "1": do_forward = True if not isinstance(do_forward, bool): return api_response(error="forward needs to be a boolean value or empty", failed=True, status_code=400)