user groups improvement.
This commit is contained in:
parent
481646aeae
commit
594acf9cbb
10
meshuser.js
10
meshuser.js
|
@ -269,6 +269,14 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||
for (var i in ids) { if (ids[i].startsWith('user/')) { userTarget = true; } }
|
||||
if (userTarget == false) { ws.send(JSON.stringify({ action: 'event', event: event })); }
|
||||
}
|
||||
} else if (event.ugrpid != null) {
|
||||
if ((user.siteadmin & SITERIGHT_USERGROUPS) != 0) {
|
||||
// If we have the rights to see users in a group, send the group as is.
|
||||
ws.send(JSON.stringify({ action: 'event', event: event }));
|
||||
} else {
|
||||
// We don't have the rights to see user groups, remove the links.
|
||||
ws.send(JSON.stringify({ action: 'event', event: { ugrpid: event.ugrpid, domain: event.domain, time: event.time, name: event.name, action: event.action, username: event.username, h: event.h } }));
|
||||
}
|
||||
} else {
|
||||
// This is not a device group event, we can get this event.
|
||||
ws.send(JSON.stringify({ action: 'event', event: event }));
|
||||
|
@ -2243,7 +2251,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||
db.Set(common.escapeLinksFieldName(mesh));
|
||||
|
||||
// Notify mesh change
|
||||
var event = { etype: 'mesh', username: newuser.name, userid: command.userid, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Added user ' + newuser.name + ' to mesh ' + mesh.name, domain: domain.id };
|
||||
var event = { etype: 'mesh', username: newuser.name, userid: user._id, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Added user ' + newuser.name + ' to mesh ' + mesh.name, domain: domain.id };
|
||||
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
|
||||
parent.parent.DispatchEvent(['*', mesh._id, user._id, newuserid], obj, event);
|
||||
removedCount++;
|
||||
|
|
|
@ -2234,8 +2234,8 @@
|
|||
} else {
|
||||
// This is an existing user group
|
||||
ugroup.name = message.event.name;
|
||||
ugroup.desc = message.event.desc;
|
||||
ugroup.links = message.event.links;
|
||||
if (message.event.desc) { ugroup.desc = message.event.desc; } else { delete ugroup.desc; }
|
||||
if (message.event.links) { ugroup.links = message.event.links; } else { delete ugroup.links; }
|
||||
}
|
||||
masterUpdate(8192 + 16384);
|
||||
break;
|
||||
|
@ -2279,7 +2279,7 @@
|
|||
if (message.event.amt) { meshes[message.event.meshid].amt = message.event.amt; }
|
||||
|
||||
// Check if we lost rights to this mesh in this change.
|
||||
if (meshes[message.event.meshid].links[userinfo._id] == null) {
|
||||
if (IsMeshViewable(message.event.meshid) == false) {
|
||||
if ((xxcurrentView == 20) && (currentMesh == meshes[message.event.meshid])) go(2);
|
||||
delete meshes[message.event.meshid];
|
||||
|
||||
|
@ -2319,6 +2319,7 @@
|
|||
// If we are looking at a node in the deleted mesh, move back to "My Devices"
|
||||
if (xxcurrentView >= 10 && xxcurrentView < 20 && currentNode && currentNode.meshid == message.event.meshid) { setDialogMode(0); go(1); }
|
||||
|
||||
console.log('deletemesh', meshes);
|
||||
break;
|
||||
}
|
||||
case 'addnode': {
|
||||
|
|
Loading…
Reference in New Issue