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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

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
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

4 个文件 +8 -6
Modified src/controllers/api/loginController.ts +1 -2
@@ -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 };
Modified src/controllers/api/logoutController.ts +1 -2
@@ -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, {
Modified src/services/wsService.ts +2 -1
@@ -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 => {
Modified static/webui/script.js +4 -1
@@ -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;