mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-13 16:03:20 -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);
|
links = parent.GetAllMeshIdWithRights(user);
|
||||||
|
|
||||||
// Add any nodes with direct rights or any nodes with user group direct rights
|
// Add any nodes with direct rights or any nodes with user group direct rights
|
||||||
if (obj.user.links != null) {
|
extraids = getUserExtraIds();
|
||||||
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); } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Request list of all nodes for one specific meshid
|
// Request list of all nodes for one specific meshid
|
||||||
meshid = command.meshid;
|
meshid = command.meshid;
|
||||||
@ -6181,6 +6171,22 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
return true;
|
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('') + '\"'; }
|
function csvClean(s) { return '\"' + s.split('\"').join('').split(',').join('').split('\r').join('').split('\n').join('') + '\"'; }
|
||||||
|
|
||||||
// Return detailed information about an array of nodeid's
|
// 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);
|
var links = parent.GetAllMeshIdWithRights(user);
|
||||||
|
|
||||||
// Add any nodes with direct rights or any nodes with user group direct rights
|
// Add any nodes with direct rights or any nodes with user group direct rights
|
||||||
var extraids = null;
|
var extraids = getUserExtraIds();
|
||||||
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); } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request a list of all nodes
|
// Request a list of all nodes
|
||||||
db.GetAllTypeNoTypeFieldMeshFiltered(links, extraids, domain.id, 'node', null, function (err, docs) {
|
db.GetAllTypeNoTypeFieldMeshFiltered(links, extraids, domain.id, 'node', null, function (err, docs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user