diff --git a/db.js b/db.js index 8463f90a..031adb83 100644 --- a/db.js +++ b/db.js @@ -101,7 +101,14 @@ module.exports.CreateDB = function (parent, func) { obj.GetAllType('mesh', function (err, docs) { if (err != null) { parent.debug('db', 'ERROR (GetAll mesh): ' + err); } var meshlist = []; - if ((err == null) && (docs.length > 0)) { for (var i in docs) { meshlist.push(docs[i]._id); } } + if ((err == null) && (docs.length > 0)) { + for (var i in docs) { + meshlist.push(docs[i]._id); + + // Make sure all mesh types are number type, if not, fix it. + if (typeof docs[i].mtype == 'string') { docs[i].mtype = parseInt(docs[i].mtype); obj.Set(docs[i]); } + } + } if ((obj.databaseType == 4) || (obj.databaseType == 5)) { // MariaDB sqlDbQuery('DELETE FROM MeshCentral.Main WHERE (extra LIKE ("mesh/%") AND (extra NOT IN ?)', [meshlist], func); diff --git a/meshuser.js b/meshuser.js index c2d2cc4d..f69e17f0 100644 --- a/meshuser.js +++ b/meshuser.js @@ -2765,6 +2765,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } case 'createmesh': { + console.log(command); + var err = null; try { // Check if we have new group restriction @@ -2776,7 +2778,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use // Create mesh else if (common.validateString(command.meshname, 1, 128) == false) { err = 'Invalid group name'; } // Meshname is between 1 and 64 characters else if ((command.desc != null) && (common.validateString(command.desc, 0, 1024) == false)) { err = 'Invalid group description'; } // Mesh description is between 0 and 1024 characters - else if ((command.meshtype != 1) && (command.meshtype != 2)) { err = 'Invalid group type'; } + else if ((command.meshtype !== 1) && (command.meshtype !== 2)) { err = 'Invalid group type'; } } catch (ex) { err = 'Validation exception: ' + ex; } // Handle any errors diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 8b80c9ba..a3c60388 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -1790,7 +1790,7 @@ } function account_createMeshEx(button, tag) { - meshserver.send({ action: 'createmesh', meshname: Q('dp3meshname').value, meshtype: Q('dp3meshtype').value, desc: Q('dp3meshdesc').value }); + meshserver.send({ action: 'createmesh', meshname: Q('dp3meshname').value, meshtype: parseInt(Q('dp3meshtype').value), desc: Q('dp3meshdesc').value }); } function account_validateDeleteAccount() { diff --git a/views/default.handlebars b/views/default.handlebars index 2edc3021..fa56cdc5 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -9583,7 +9583,7 @@ } function account_createMeshEx(button, tag) { - meshserver.send({ action: 'createmesh', meshname: Q('dp2meshname').value, meshtype: Q('dp2meshtype').value, desc: Q('dp2meshdesc').value }); + meshserver.send({ action: 'createmesh', meshname: Q('dp2meshname').value, meshtype: parseInt(Q('dp2meshtype').value), desc: Q('dp2meshdesc').value }); } function account_validateDeleteAccount() {