From 6394adb0f08881eb05ad417c182431bafa5fe8f2 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Fri, 18 Apr 2025 11:17:55 -0700 Subject: [PATCH] fix(webui): handle config get request failing due to expired authz (#1716) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1716 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- static/webui/script.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index b56e2f6e..e8e4821e 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1315,7 +1315,7 @@ single.getRoute("/webui/cheats").on("beforeload", function () { interval = setInterval(() => { if (window.authz) { clearInterval(interval); - fetch("/custom/config?" + window.authz).then(res => { + fetch("/custom/config?" + window.authz).then(async res => { if (res.status == 200) { $("#server-settings-no-perms").addClass("d-none"); $("#server-settings").removeClass("d-none"); @@ -1335,8 +1335,16 @@ single.getRoute("/webui/cheats").on("beforeload", function () { }) ); } else { - $("#server-settings-no-perms").removeClass("d-none"); - $("#server-settings").addClass("d-none"); + if ((await res.text()) == "Log-in expired") { + revalidateAuthz(() => { + if (single.getCurrentPath() == "/webui/cheats") { + single.loadRoute("/webui/cheats"); + } + }); + } else { + $("#server-settings-no-perms").removeClass("d-none"); + $("#server-settings").addClass("d-none"); + } } }); }