Update from upstream (#271)

* Fix

* Fix

* Fix logout

* Fix logout

* Fix

* WIP
This commit is contained in:
Louis Lam
2023-12-10 21:16:23 +08:00
committed by GitHub
parent 587d2dcaca
commit 07c52ccebb
5 changed files with 137 additions and 4 deletions

View File

@@ -211,6 +211,8 @@ export class MainSocketHandler extends SocketHandler {
let user = await doubleCheckPassword(socket, password.currentPassword);
await user.resetPassword(password.newPassword);
server.disconnectAllSocketClients(user.id, socket.id);
callback({
ok: true,
msg: "Password has been updated successfully.",
@@ -280,6 +282,18 @@ export class MainSocketHandler extends SocketHandler {
}
}
});
// Disconnect all other socket clients of the user
socket.on("disconnectOtherSocketClients", async () => {
try {
checkLogin(socket);
server.disconnectAllSocketClients(socket.userID, socket.id);
} catch (e) {
if (e instanceof Error) {
log.warn("disconnectOtherSocketClients", e.message);
}
}
});
}
async login(username : string, password : string) : Promise<User | null> {