feat: Disconnect sockets for deactivated users in saveUser function

This commit is contained in:
Ionys 2025-06-26 17:08:21 +02:00
parent 923d0ede7e
commit 28dc77f9e3
3 changed files with 9 additions and 4 deletions

View file

@ -68,6 +68,12 @@ async function saveUser(socket, user) {
io.to(socket.userID).emit("saveUser", bean);
// If user is deactivated, disconnect his sockets
if (!bean.active) {
const roomId = typeof id === "number" ? id : parseInt(id, 10);
io.in(roomId).disconnectSockets();
}
timeLogger.print(`Save user ${user.id}`);
}

View file

@ -1,6 +1,6 @@
<template>
<div :class="classes">
<div v-if="! $root.socket.connected && ! $root.socket.firstConnect" class="lost-connection">
<div v-if="! $root.socket.connected && ! $root.socket.firstConnect" class="lost-connection" data-testid="lost-connection">
<div class="container-fluid">
{{ $root.connectionErrorMsg }}
<div v-if="$root.showReverseProxyGuide">

View file

@ -34,12 +34,11 @@ test.describe("Multiple Users", () => {
// Disable the admin user
await page.getByTestId("toggle-active-user-admin").click();
// Click on the button containing Yes and having btn-danger class
await page.getByRole("button", {
name: "Yes",
exact: true
}).click();
await expect(page.getByText("You are not logged in.")).toBeVisible();
await expect(page.getByTestId("lost-connection")).toBeVisible();
// Make sure we're back on the login page after refresh
await page.reload();
@ -52,8 +51,8 @@ test.describe("Multiple Users", () => {
// Disable self-user
await page.goto("./settings/users/edit/2");
await expect(page.getByTestId("active-checkbox")).toBeVisible();
await page.getByTestId("active-checkbox").uncheck();
await expect(page.getByTestId("lost-connection")).toBeVisible();
await screenshot(testInfo, page);