mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-10-29 15:25:01 -04:00
fix usergroup links not being removed correctly #7198
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
27472852a2
commit
5c5bcb4152
14
db.js
14
db.js
@ -261,6 +261,20 @@ module.exports.CreateDB = function (parent, func) {
|
||||
if (obj.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
|
||||
parent.DispatchEvent(targets, obj, event);
|
||||
}
|
||||
} else if (i.startsWith('ugrp/')) {
|
||||
var cusergroup = parent.userGroups[i];
|
||||
if ((cusergroup != null) && (cusergroup.links != null) && (cusergroup.links[node._id] != null)) {
|
||||
// Remove the user link & save the user
|
||||
delete cusergroup.links[node._id];
|
||||
if (Object.keys(cusergroup.links).length == 0) { delete cusergroup.links; }
|
||||
obj.Set(cusergroup);
|
||||
|
||||
// Notify user change
|
||||
var targets = ['*', 'server-users', cusergroup._id];
|
||||
var event = { etype: 'ugrp', ugrpid: cusergroup._id, name: cusergroup.name, desc: cusergroup.desc, action: 'usergroupchange', links: cusergroup.links, msgid: 163, msgArgs: [node.name, cusergroup.name], msg: 'Removed device ' + node.name + ' from user group ' + cusergroup.name };
|
||||
if (obj.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
|
||||
parent.DispatchEvent(targets, obj, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
meshuser.js
15
meshuser.js
@ -2847,6 +2847,21 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
|
||||
parent.parent.DispatchEvent(targets, obj, event);
|
||||
}
|
||||
} else if (i.startsWith('ugrp/')) {
|
||||
var cusergroup = parent.userGroups[i];
|
||||
console.log(cusergroup);
|
||||
if ((cusergroup != null) && (cusergroup.links != null) && (cusergroup.links[node._id] != null)) {
|
||||
// Remove the user link & save the user
|
||||
delete cusergroup.links[node._id];
|
||||
if (Object.keys(cusergroup.links).length == 0) { delete cusergroup.links; }
|
||||
db.Set(cusergroup);
|
||||
|
||||
// Notify user change
|
||||
var targets = ['*', 'server-users', cusergroup._id];
|
||||
var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: cusergroup._id, name: cusergroup.name, desc: cusergroup.desc, action: 'usergroupchange', links: cusergroup.links, msgid: 163, msgArgs: [node.name, cusergroup.name], msg: 'Removed device ' + node.name + ' from user group ' + cusergroup.name };
|
||||
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
|
||||
parent.parent.DispatchEvent(targets, obj, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -15411,7 +15411,8 @@
|
||||
159: "Device Powered On",
|
||||
160: "Enabled Duo two-factor authentication",
|
||||
161: "Disabled Duo two-factor authentication",
|
||||
162: "Started messenger session \"{0}\" from {1} to {2}"
|
||||
162: "Started messenger session \"{0}\" from {1} to {2}",
|
||||
163: "Removed device {0} from user group {1}"
|
||||
};
|
||||
|
||||
var eventsShortMessageId = {
|
||||
|
||||
@ -16569,7 +16569,8 @@
|
||||
159: "Device Powered On",
|
||||
160: "Enabled Duo two-factor authentication",
|
||||
161: "Disabled Duo two-factor authentication",
|
||||
162: "Started messenger session \"{0}\" from {1} to {2}"
|
||||
162: "Started messenger session \"{0}\" from {1} to {2}",
|
||||
163: "Removed device {0} from user group {1}"
|
||||
};
|
||||
|
||||
var eventsShortMessageId = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user