XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

fix(webui): perform a consistent transition when changing accounts (#3795)

Closes #3794 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3795 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

76d186c4
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +11 -4
Modified static/webui/script.js +11 -4
@@ -94,7 +94,7 @@ function openWebSocket() {
94 94 auth_pending = false;
95 95 if (localStorage.getItem("possessing")) {
96 96 localStorage.removeItem("possessing");
97 sendAuth();
97 doAccountSwitch("/webui/admin");
98 98 } else {
99 99 logout();
100 100 if (single.getCurrentPath() == "/webui/") {
@@ -125,7 +125,7 @@ function openWebSocket() {
125 125 if ("logged_out" in msg) {
126 126 if (localStorage.getItem("possessing")) {
127 127 localStorage.removeItem("possessing");
128 sendAuth();
128 doAccountSwitch("/webui/admin");
129 129 } else {
130 130 logout();
131 131 single.loadRoute("/webui/"); // Show login screen
@@ -155,6 +155,13 @@ function refreshServerConfig() {
155 155 }
156 156 }
157 157
158 function doAccountSwitch(to_route) {
159 window.authz = undefined;
160 did_initial_auth = false;
161 single.loadRoute(to_route);
162 sendAuth();
163 }
164
158 165 function getWebSocket() {
159 166 return new Promise(resolve => {
160 167 let interval;
@@ -200,7 +207,7 @@ function logout() {
200 207 function doLogout() {
201 208 if (localStorage.getItem("possessing")) {
202 209 localStorage.removeItem("possessing");
203 location.href = "/webui/inventory";
210 doAccountSwitch("/webui/admin");
204 211 } else {
205 212 logout();
206 213 if (ws_is_open) {
@@ -5257,7 +5264,7 @@ single.getRoute("/webui/admin").on("beforeload", function () {
5257 5264 a.href = "#";
5258 5265 a.onclick = function () {
5259 5266 localStorage.setItem("possessing", user.id);
5260 location.href = "/webui/inventory";
5267 doAccountSwitch("/webui/inventory");
5261 5268 };
5262 5269 td.appendChild(a);
5263 5270 }