mirror of
https://github.com/louislam/dockge.git
synced 2025-02-18 03:21:13 +01:00
Fix logout
This commit is contained in:
parent
16a5f2a175
commit
fd7f539089
@ -610,7 +610,7 @@ export class DockgeServer {
|
|||||||
* @param {string} userID
|
* @param {string} userID
|
||||||
* @param {string?} currentSocketID
|
* @param {string?} currentSocketID
|
||||||
*/
|
*/
|
||||||
disconnectAllSocketClient(userID: number, currentSocketID? : string) {
|
disconnectAllSocketClients(userID: number, currentSocketID? : string) {
|
||||||
for (const rawSocket of this.io.sockets.sockets.values()) {
|
for (const rawSocket of this.io.sockets.sockets.values()) {
|
||||||
let socket = rawSocket as DockgeSocket;
|
let socket = rawSocket as DockgeSocket;
|
||||||
if (socket.userID === userID && socket.id !== currentSocketID) {
|
if (socket.userID === userID && socket.id !== currentSocketID) {
|
||||||
|
@ -211,7 +211,7 @@ export class MainSocketHandler extends SocketHandler {
|
|||||||
let user = await doubleCheckPassword(socket, password.currentPassword);
|
let user = await doubleCheckPassword(socket, password.currentPassword);
|
||||||
await user.resetPassword(password.newPassword);
|
await user.resetPassword(password.newPassword);
|
||||||
|
|
||||||
server.disconnectAllSocketClient(user.id, socket.id);
|
server.disconnectAllSocketClients(user.id, socket.id);
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
ok: true,
|
ok: true,
|
||||||
@ -282,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> {
|
async login(username : string, password : string) : Promise<User | null> {
|
||||||
|
@ -48,6 +48,8 @@ export const main = async () => {
|
|||||||
// Reset all sessions by reset jwt secret
|
// Reset all sessions by reset jwt secret
|
||||||
await server.initJWTSecret();
|
await server.initJWTSecret();
|
||||||
|
|
||||||
|
console.log("Password reset successfully.");
|
||||||
|
|
||||||
// Disconnect all other socket clients of the user
|
// Disconnect all other socket clients of the user
|
||||||
await disconnectAllSocketClients(user.username, password);
|
await disconnectAllSocketClients(user.username, password);
|
||||||
|
|
||||||
@ -56,7 +58,6 @@ export const main = async () => {
|
|||||||
console.log("Passwords do not match, please try again.");
|
console.log("Passwords do not match, please try again.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Password reset successfully.");
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user