fix: Prevent deactivated users from receiving socket events when possible

This commit is contained in:
Maksim Eltyshev
2026-01-23 19:38:58 +01:00
parent 6ec0bafecb
commit 267fce0505
6 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ module.exports = {
const config = await Config.qm.updateOneMain(values);
const configRelatedUserIds = await sails.helpers.users.getAllIds(User.Roles.ADMIN);
const configRelatedUserIds = await sails.helpers.users.getAllActiveIds(User.Roles.ADMIN);
configRelatedUserIds.forEach((userId) => {
sails.sockets.broadcast(
@@ -29,6 +29,7 @@ module.exports = {
if (deactivatedUserIds && deactivatedUserIds.length > 0) {
const users = await User.qm.getAll({
roleOrRoles: [User.Roles.ADMIN, User.Roles.PROJECT_OWNER],
isDeactivated: false,
});
adminUserIds = users.flatMap((user) => {
@@ -37,7 +38,7 @@ module.exports = {
return user.role === User.Roles.ADMIN ? user.id : [];
});
} else {
adminUserIds = await sails.helpers.users.getAllIds(User.Roles.ADMIN);
adminUserIds = await sails.helpers.users.getAllActiveIds(User.Roles.ADMIN);
}
adminUserIds.forEach((userId) => {
+1 -1
View File
@@ -71,7 +71,7 @@ class Scoper {
async getAdminUserIds() {
if (!this.adminUserIds) {
this.adminUserIds = await sails.helpers.users.getAllIds(User.Roles.ADMIN);
this.adminUserIds = await sails.helpers.users.getAllActiveIds(User.Roles.ADMIN);
}
return this.adminUserIds;
@@ -14,6 +14,7 @@ module.exports = {
async fn(inputs) {
const users = await User.qm.getAll({
roleOrRoles: inputs.roleOrRoles,
isDeactivated: false,
});
return sails.helpers.utils.mapRecords(users);
+1
View File
@@ -28,6 +28,7 @@ class Scoper {
if (!this.separatedUserIds) {
const users = await User.qm.getAll({
roleOrRoles: [User.Roles.ADMIN, User.Roles.PROJECT_OWNER],
isDeactivated: false,
});
const adminUserIds = [];
@@ -60,8 +60,9 @@ const getByIds = (ids, { withDeactivated = true } = {}) => {
return defaultFind(criteria);
};
const getAll = ({ roleOrRoles } = {}) =>
const getAll = ({ roleOrRoles, isDeactivated } = {}) =>
defaultFind({
isDeactivated,
role: roleOrRoles,
});