mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-25 22:55:52 -05:00
Factor out meshuser extraids
This commit is contained in:
parent
1034b79a66
commit
da8947d25e
41
meshuser.js
41
meshuser.js
@ -657,17 +657,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
links = parent.GetAllMeshIdWithRights(user);
|
||||
|
||||
// Add any nodes with direct rights or any nodes with user group direct rights
|
||||
if (obj.user.links != null) {
|
||||
for (var i in obj.user.links) {
|
||||
if (i.startsWith('node/')) { if (extraids == null) { extraids = []; } extraids.push(i); }
|
||||
else if (i.startsWith('ugrp/')) {
|
||||
const g = parent.userGroups[i];
|
||||
if ((g != null) && (g.links != null)) {
|
||||
for (var j in g.links) { if (j.startsWith('node/')) { if (extraids == null) { extraids = []; } extraids.push(j); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
extraids = getUserExtraIds();
|
||||
} else {
|
||||
// Request list of all nodes for one specific meshid
|
||||
meshid = command.meshid;
|
||||
@ -6181,6 +6171,22 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
return true;
|
||||
}
|
||||
|
||||
function getUserExtraIds() {
|
||||
var extraids = null;
|
||||
if (obj.user.links != null) {
|
||||
for (var i in obj.user.links) {
|
||||
if (i.startsWith('node/')) { if (extraids == null) { extraids = []; } extraids.push(i); }
|
||||
else if (i.startsWith('ugrp/')) {
|
||||
const g = parent.userGroups[i];
|
||||
if ((g != null) && (g.links != null)) {
|
||||
for (var j in g.links) { if (j.startsWith('node/')) { if (extraids == null) { extraids = []; } extraids.push(j); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return extraids;
|
||||
}
|
||||
|
||||
function csvClean(s) { return '\"' + s.split('\"').join('').split(',').join('').split('\r').join('').split('\n').join('') + '\"'; }
|
||||
|
||||
// Return detailed information about an array of nodeid's
|
||||
@ -6229,18 +6235,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
var links = parent.GetAllMeshIdWithRights(user);
|
||||
|
||||
// Add any nodes with direct rights or any nodes with user group direct rights
|
||||
var extraids = null;
|
||||
if (obj.user.links != null) {
|
||||
for (var i in obj.user.links) {
|
||||
if (i.startsWith('node/')) { if (extraids == null) { extraids = []; } extraids.push(i); }
|
||||
else if (i.startsWith('ugrp/')) {
|
||||
const g = parent.userGroups[i];
|
||||
if ((g != null) && (g.links != null)) {
|
||||
for (var j in g.links) { if (j.startsWith('node/')) { if (extraids == null) { extraids = []; } extraids.push(j); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var extraids = getUserExtraIds();
|
||||
|
||||
// Request a list of all nodes
|
||||
db.GetAllTypeNoTypeFieldMeshFiltered(links, extraids, domain.id, 'node', null, function (err, docs) {
|
||||
|
Loading…
Reference in New Issue
Block a user