返回提交历史
Modified
src/services/wsService.ts
+5
-1
Modified
static/webui/script.js
+6
-1
XFEstudio/XFESpaceNinjaServer
fix(webui): properly sync logout across multiple browsers/tabs (#3077)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3077 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
ad402917
代码差异
2 个文件
+11
-2
@@ -177,7 +177,8 @@ const wsOnConnect = (ws: WebSocket, req: http.IncomingMessage): void => {
177
177
const accountId = (ws as IWsCustomData).accountId;
178
178
if (accountId) {
179
179
(ws as IWsCustomData).accountId = undefined;
180
await Account.updateOne(
180
181
const stat = await Account.updateOne(
181
182
{
182
183
_id: accountId,
183
184
ClientType: "webui"
@@ -186,6 +187,9 @@ const wsOnConnect = (ws: WebSocket, req: http.IncomingMessage): void => {
186
187
Nonce: 0
187
188
}
188
189
);
190
if (stat.modifiedCount) {
191
handleNonceInvalidation(accountId);
192
}
189
193
}
190
194
}
191
195
if (data.sync_inventory) {
@@ -24,7 +24,9 @@ const sendAuth = isRegister => {
24
24
}
25
25
})
26
26
);
27
return true;
27
28
}
29
return false;
28
30
};
29
31
30
32
function openWebSocket() {
@@ -84,13 +86,16 @@ function openWebSocket() {
84
86
}
85
87
}
86
88
if ("nonce_updated" in msg) {
87
sendAuth();
89
if (!sendAuth()) {
90
single.loadRoute("/webui/"); // Show login screen
91
}
88
92
}
89
93
if ("update_inventory" in msg) {
90
94
updateInventory();
91
95
}
92
96
if ("logged_out" in msg) {
93
97
logout();
98
single.loadRoute("/webui/"); // Show login screen
94
99
}
95
100
if ("have_game_ws" in msg) {
96
101
window.have_game_ws = msg.have_game_ws;