返回提交历史
Modified
src/controllers/api/loginController.ts
+1
-2
Modified
src/controllers/api/logoutController.ts
+1
-2
Modified
src/services/wsService.ts
+2
-1
Modified
static/webui/script.js
+4
-1
XFEstudio/XFESpaceNinjaServer
fix(webui): differentiate between nonce invalidation & forced logout (#2658)
Closes #2642 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2658 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
660c3f3d
代码差异
4 个文件
+8
-6
@@ -88,8 +88,7 @@ export const loginController: RequestHandler = async (request, response) => {
88
88
account.LastLogin = new Date();
89
89
await account.save();
90
90
91
// Tell WebUI its nonce has been invalidated
92
sendWsBroadcastTo(account._id.toString(), { logged_out: true });
91
sendWsBroadcastTo(account._id.toString(), { nonce_updated: true });
93
92
94
93
response.json(createLoginResponse(myAddress, myUrlBase, account.toJSON(), buildLabel));
95
94
};
@@ -21,8 +21,7 @@ export const logoutController: RequestHandler = async (req, res) => {
21
21
}
22
22
);
23
23
if (stat.modifiedCount) {
24
// Tell WebUI its nonce has been invalidated
25
sendWsBroadcastTo(req.query.accountId as string, { logged_out: true });
24
sendWsBroadcastTo(req.query.accountId as string, { nonce_updated: true });
26
25
}
27
26
28
27
res.writeHead(200, {
@@ -73,8 +73,9 @@ interface IWsMsgToClient {
73
73
auth_fail?: {
74
74
isRegister: boolean;
75
75
};
76
logged_out?: boolean;
76
nonce_updated?: boolean;
77
77
update_inventory?: boolean;
78
logged_out?: boolean;
78
79
}
79
80
80
81
const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {
@@ -81,12 +81,15 @@ function openWebSocket() {
81
81
single.loadRoute("/webui/");
82
82
}
83
83
}
84
if ("logged_out" in msg) {
84
if ("nonce_updated" in msg) {
85
85
sendAuth();
86
86
}
87
87
if ("update_inventory" in msg) {
88
88
updateInventory();
89
89
}
90
if ("logged_out" in msg) {
91
logout();
92
}
90
93
};
91
94
window.ws.onclose = function () {
92
95
ws_is_open = false;