mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-14 12:01:52 +00:00
Factor out node id and domain validation
This commit is contained in:
parent
c4b11d3384
commit
34aab9c10a
1 changed files with 8 additions and 7 deletions
15
meshuser.js
15
meshuser.js
|
@ -5532,10 +5532,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
};
|
};
|
||||||
|
|
||||||
function serverCommandGetNetworkInfo(command) {
|
function serverCommandGetNetworkInfo(command) {
|
||||||
// Argument validation
|
if (!validNodeIdAndDomain(command)) return;
|
||||||
if (common.validateString(command.nodeid, 1, 1024) == false) return; // Check nodeid
|
|
||||||
if (command.nodeid.indexOf('/') == -1) { command.nodeid = 'node/' + domain.id + '/' + command.nodeid; }
|
|
||||||
if ((command.nodeid.split('/').length != 3) || (command.nodeid.split('/')[1] != domain.id)) return; // Invalid domain, operation only valid for current domain
|
|
||||||
|
|
||||||
// Get the node and the rights for this node
|
// Get the node and the rights for this node
|
||||||
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
|
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
|
||||||
|
@ -5560,9 +5557,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
}
|
}
|
||||||
|
|
||||||
function serverCommandLastConnect(command) {
|
function serverCommandLastConnect(command) {
|
||||||
if (common.validateString(command.nodeid, 1, 1024) == false) return; // Check the nodeid
|
if (!validNodeIdAndDomain(command)) return;
|
||||||
if (command.nodeid.indexOf('/') == -1) { command.nodeid = 'node/' + domain.id + '/' + command.nodeid; }
|
|
||||||
if ((command.nodeid.split('/').length != 3) || (command.nodeid.split('/')[1] != domain.id)) return; // Invalid domain, operation only valid for current domain
|
|
||||||
|
|
||||||
// Get the node and the rights for this node
|
// Get the node and the rights for this node
|
||||||
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
|
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
|
||||||
|
@ -6154,6 +6149,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function validNodeIdAndDomain(command) {
|
||||||
|
if (common.validateString(command.nodeid, 1, 1024) == false) return false; // Check nodeid
|
||||||
|
if (command.nodeid.indexOf('/') == -1) { command.nodeid = 'node/' + domain.id + '/' + command.nodeid; }
|
||||||
|
if ((command.nodeid.split('/').length != 3) || (command.nodeid.split('/')[1] != domain.id)) return false; // Invalid domain, operation only valid for current domain
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
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('') + '\"'; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue