fix(webui): differentiate between nonce invalidation & forced logout #2658

Merged
Sainan merged 1 commits from delete-fix into main 2025-08-17 13:12:30 -07:00
4 changed files with 8 additions and 6 deletions

View File

@ -88,8 +88,7 @@ export const loginController: RequestHandler = async (request, response) => {
account.LastLogin = new Date(); account.LastLogin = new Date();
await account.save(); await account.save();
// Tell WebUI its nonce has been invalidated sendWsBroadcastTo(account._id.toString(), { nonce_updated: true });
sendWsBroadcastTo(account._id.toString(), { logged_out: true });
response.json(createLoginResponse(myAddress, myUrlBase, account.toJSON(), buildLabel)); response.json(createLoginResponse(myAddress, myUrlBase, account.toJSON(), buildLabel));
}; };

View File

@ -21,8 +21,7 @@ export const logoutController: RequestHandler = async (req, res) => {
} }
); );
if (stat.modifiedCount) { if (stat.modifiedCount) {
// Tell WebUI its nonce has been invalidated sendWsBroadcastTo(req.query.accountId as string, { nonce_updated: true });
sendWsBroadcastTo(req.query.accountId as string, { logged_out: true });
} }
res.writeHead(200, { res.writeHead(200, {

View File

@ -73,8 +73,9 @@ interface IWsMsgToClient {
auth_fail?: { auth_fail?: {
isRegister: boolean; isRegister: boolean;
}; };
logged_out?: boolean; nonce_updated?: boolean;
update_inventory?: boolean; update_inventory?: boolean;
logged_out?: boolean;
} }
const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => { const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {

View File

@ -81,12 +81,15 @@ function openWebSocket() {
single.loadRoute("/webui/"); single.loadRoute("/webui/");
} }
} }
if ("logged_out" in msg) { if ("nonce_updated" in msg) {
sendAuth(); sendAuth();
} }
if ("update_inventory" in msg) { if ("update_inventory" in msg) {
updateInventory(); updateInventory();
} }
if ("logged_out" in msg) {
logout();
}
}; };
window.ws.onclose = function () { window.ws.onclose = function () {
ws_is_open = false; ws_is_open = false;