Fixed mtype not being a number type in database.

This commit is contained in:
Ylian Saint-Hilaire 2020-12-28 23:33:08 -08:00
parent 8fc23995b9
commit 0769185831
4 changed files with 13 additions and 4 deletions

9
db.js
View File

@ -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);

View File

@ -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

View File

@ -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() {

View File

@ -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() {