Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly handle forward values (can be string or boolean, even though… #852

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rcongui/src/pages/settings/autosettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"});
};
Expand Down
6 changes: 6 additions & 0 deletions rconweb/api/auto_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" or do_forward == "0":
do_forward = False
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)

settings = data.get("settings")
if not settings:
Expand Down
Loading