mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-07 12:52:54 -05:00
fix usergroup links not being removed correctly #7198
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user