fix(webui): differentiate between nonce invalidation & forced logout (#2658)
Closes #2642 Reviewed-on: OpenWF/SpaceNinjaServer#2658 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
024b806af1
commit
660c3f3ddf
@ -88,8 +88,7 @@ export const loginController: RequestHandler = async (request, response) => {
|
||||
account.LastLogin = new Date();
|
||||
await account.save();
|
||||
|
||||
// Tell WebUI its nonce has been invalidated
|
||||
sendWsBroadcastTo(account._id.toString(), { logged_out: true });
|
||||
sendWsBroadcastTo(account._id.toString(), { nonce_updated: true });
|
||||
|
||||
response.json(createLoginResponse(myAddress, myUrlBase, account.toJSON(), buildLabel));
|
||||
};
|
||||
|
||||
@ -21,8 +21,7 @@ export const logoutController: RequestHandler = async (req, res) => {
|
||||
}
|
||||
);
|
||||
if (stat.modifiedCount) {
|
||||
// Tell WebUI its nonce has been invalidated
|
||||
sendWsBroadcastTo(req.query.accountId as string, { logged_out: true });
|
||||
sendWsBroadcastTo(req.query.accountId as string, { nonce_updated: true });
|
||||
}
|
||||
|
||||
res.writeHead(200, {
|
||||
|
||||
@ -73,8 +73,9 @@ interface IWsMsgToClient {
|
||||
auth_fail?: {
|
||||
isRegister: boolean;
|
||||
};
|
||||
logged_out?: boolean;
|
||||
nonce_updated?: boolean;
|
||||
update_inventory?: boolean;
|
||||
logged_out?: boolean;
|
||||
}
|
||||
|
||||
const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {
|
||||
|
||||
@ -81,12 +81,15 @@ function openWebSocket() {
|
||||
single.loadRoute("/webui/");
|
||||
}
|
||||
}
|
||||
if ("logged_out" in msg) {
|
||||
if ("nonce_updated" in msg) {
|
||||
sendAuth();
|
||||
}
|
||||
if ("update_inventory" in msg) {
|
||||
updateInventory();
|
||||
}
|
||||
if ("logged_out" in msg) {
|
||||
logout();
|
||||
}
|
||||
};
|
||||
window.ws.onclose = function () {
|
||||
ws_is_open = false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user