mirror of
https://github.com/plankanban/planka.git
synced 2026-09-19 01:44:45 +08:00
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 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) => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
@@ -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);
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user