fix removedevice with meshctrl (#5487)
Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Oct 31, 2023 at 19:11 UTC
cb87cc8172c4a873bb84281d90242cba3b747a4d
1 file changed
+13
-1
meshuser.js
+13
-1
@@ -2738,8 +2738,20 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2738
{
2739
if (common.validateArray(command.nodeids, 1) == false) break; // Check nodeid's
2740
for (i in command.nodeids) {
2741
+ var nodeid = command.nodeids[i], err = null;
2742
+
2743
+ // Argument validation
2744
+ if (common.validateString(nodeid, 1, 1024) == false) { err = 'Invalid nodeid'; } // Check nodeid
2745
+ else {
2746
+ if (nodeid.indexOf('/') == -1) { nodeid = 'node/' + domain.id + '/' + nodeid; }
2747
+ if ((nodeid.split('/').length != 3) || (nodeid.split('/')[1] != domain.id)) { err = 'Invalid domain'; } // Invalid domain, operation only valid for current domain
2748
+ }
2749
+ if (err != null) {
2750
+ if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'removedevices', responseid: command.responseid, result: err })); } catch (ex) { } }
2751
+ continue;
2752
+ }
2753
// Get the node and the rights for this node
2742
- parent.GetNodeWithRights(domain, user, command.nodeids[i], function (node, rights, visible) {
2754
+ parent.GetNodeWithRights(domain, user, nodeid, function (node, rights, visible) {
2755
// Check we have the rights to delete this device
2756
if ((rights & MESHRIGHT_UNINSTALL) == 0) return;
2757