fix: Prevent deactivated users from receiving socket events when possible
This commit is contained in:
@@ -23,7 +23,7 @@ module.exports = {
|
|||||||
|
|
||||||
const config = await Config.qm.updateOneMain(values);
|
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) => {
|
configRelatedUserIds.forEach((userId) => {
|
||||||
sails.sockets.broadcast(
|
sails.sockets.broadcast(
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ module.exports = {
|
|||||||
if (deactivatedUserIds && deactivatedUserIds.length > 0) {
|
if (deactivatedUserIds && deactivatedUserIds.length > 0) {
|
||||||
const users = await User.qm.getAll({
|
const users = await User.qm.getAll({
|
||||||
roleOrRoles: [User.Roles.ADMIN, User.Roles.PROJECT_OWNER],
|
roleOrRoles: [User.Roles.ADMIN, User.Roles.PROJECT_OWNER],
|
||||||
|
isDeactivated: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
adminUserIds = users.flatMap((user) => {
|
adminUserIds = users.flatMap((user) => {
|
||||||
@@ -37,7 +38,7 @@ module.exports = {
|
|||||||
return user.role === User.Roles.ADMIN ? user.id : [];
|
return user.role === User.Roles.ADMIN ? user.id : [];
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
adminUserIds = await sails.helpers.users.getAllIds(User.Roles.ADMIN);
|
adminUserIds = await sails.helpers.users.getAllActiveIds(User.Roles.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
adminUserIds.forEach((userId) => {
|
adminUserIds.forEach((userId) => {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class Scoper {
|
|||||||
|
|
||||||
async getAdminUserIds() {
|
async getAdminUserIds() {
|
||||||
if (!this.adminUserIds) {
|
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;
|
return this.adminUserIds;
|
||||||
|
|||||||
+1
@@ -14,6 +14,7 @@ module.exports = {
|
|||||||
async fn(inputs) {
|
async fn(inputs) {
|
||||||
const users = await User.qm.getAll({
|
const users = await User.qm.getAll({
|
||||||
roleOrRoles: inputs.roleOrRoles,
|
roleOrRoles: inputs.roleOrRoles,
|
||||||
|
isDeactivated: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
return sails.helpers.utils.mapRecords(users);
|
return sails.helpers.utils.mapRecords(users);
|
||||||
@@ -28,6 +28,7 @@ class Scoper {
|
|||||||
if (!this.separatedUserIds) {
|
if (!this.separatedUserIds) {
|
||||||
const users = await User.qm.getAll({
|
const users = await User.qm.getAll({
|
||||||
roleOrRoles: [User.Roles.ADMIN, User.Roles.PROJECT_OWNER],
|
roleOrRoles: [User.Roles.ADMIN, User.Roles.PROJECT_OWNER],
|
||||||
|
isDeactivated: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const adminUserIds = [];
|
const adminUserIds = [];
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ const getByIds = (ids, { withDeactivated = true } = {}) => {
|
|||||||
return defaultFind(criteria);
|
return defaultFind(criteria);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAll = ({ roleOrRoles } = {}) =>
|
const getAll = ({ roleOrRoles, isDeactivated } = {}) =>
|
||||||
defaultFind({
|
defaultFind({
|
||||||
|
isDeactivated,
|
||||||
role: roleOrRoles,
|
role: roleOrRoles,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user