diff --git a/meshuser.js b/meshuser.js index 2d655efa..80efe729 100644 --- a/meshuser.js +++ b/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) {