Probably fixed the MongoDB dot exception.

This commit is contained in:
Ylian Saint-Hilaire 2019-10-10 14:06:14 -07:00
parent 483f270a23
commit fcccb18cc8
5 changed files with 30 additions and 30 deletions

36
db.js
View File

@ -608,11 +608,11 @@ module.exports.CreateDB = function (parent, func) {
} }
// Check the object names for a "." // Check the object names for a "."
function checkObjectNames(r) { function checkObjectNames(r, tag) {
if (typeof r != 'object') return; if (typeof r != 'object') return;
for (var i in r) { for (var i in r) {
if (i.indexOf('.') >= 0) { throw('BadDbName: ' + JSON.stringify(r)); } if (i.indexOf('.') >= 0) { throw('BadDbName (' + tag + '): ' + JSON.stringify(r)); }
checkObjectNames(r[i]); checkObjectNames(r[i], tag);
} }
} }
@ -620,7 +620,7 @@ module.exports.CreateDB = function (parent, func) {
if (obj.databaseType == 3) { if (obj.databaseType == 3) {
// Database actions on the main collection (MongoDB) // Database actions on the main collection (MongoDB)
obj.Set = function (data, func) { obj.Set = function (data, func) {
checkObjectNames(data); // DEBUG CHECKING checkObjectNames(data, 'x1'); // DEBUG CHECKING
obj.file.replaceOne({ _id: data._id }, performTypedRecordEncrypt(data), { upsert: true }, func); obj.file.replaceOne({ _id: data._id }, performTypedRecordEncrypt(data), { upsert: true }, func);
}; };
obj.Get = function (id, func) { obj.Get = function (id, func) {
@ -651,21 +651,21 @@ module.exports.CreateDB = function (parent, func) {
obj.RemoveAll = function (func) { obj.file.deleteMany({}, { multi: true }, func); }; obj.RemoveAll = function (func) { obj.file.deleteMany({}, { multi: true }, func); };
obj.RemoveAllOfType = function (type, func) { obj.file.deleteMany({ type: type }, { multi: true }, func); }; obj.RemoveAllOfType = function (type, func) { obj.file.deleteMany({ type: type }, { multi: true }, func); };
obj.InsertMany = function (data, func) { obj.InsertMany = function (data, func) {
checkObjectNames(data); // DEBUG CHECKING checkObjectNames(data, 'x2'); // DEBUG CHECKING
obj.file.insertMany(data, func); obj.file.insertMany(data, func);
}; };
obj.RemoveMeshDocuments = function (id) { obj.file.deleteMany({ meshid: id }, { multi: true }); obj.file.deleteOne({ _id: 'nt' + id }); }; obj.RemoveMeshDocuments = function (id) { obj.file.deleteMany({ meshid: id }, { multi: true }); obj.file.deleteOne({ _id: 'nt' + id }); };
obj.MakeSiteAdmin = function (username, domain) { obj.MakeSiteAdmin = function (username, domain) {
obj.Get('user/' + domain + '/' + username, function (err, docs) { obj.Get('user/' + domain + '/' + username, function (err, docs) {
if (docs.length == 1) { if (docs.length == 1) {
checkObjectNames(docs[0]); // DEBUG CHECKING checkObjectNames(docs[0], 'x3'); // DEBUG CHECKING
docs[0].siteadmin = 0xFFFFFFFF; obj.Set(docs[0]); docs[0].siteadmin = 0xFFFFFFFF; obj.Set(docs[0]);
} }
}); });
}; };
obj.DeleteDomain = function (domain, func) { obj.file.deleteMany({ domain: domain }, { multi: true }, func); }; obj.DeleteDomain = function (domain, func) { obj.file.deleteMany({ domain: domain }, { multi: true }, func); };
obj.SetUser = function (user) { obj.SetUser = function (user) {
checkObjectNames(user); // DEBUG CHECKING checkObjectNames(user, 'x4'); // DEBUG CHECKING
var u = Clone(user); var u = Clone(user);
if (u.subscriptions) { delete u.subscriptions; } obj.Set(u); if (u.subscriptions) { delete u.subscriptions; } obj.Set(u);
}; };
@ -681,7 +681,7 @@ module.exports.CreateDB = function (parent, func) {
// Database actions on the events collection // Database actions on the events collection
obj.GetAllEvents = function (func) { obj.eventsfile.find({}).toArray(func); }; obj.GetAllEvents = function (func) { obj.eventsfile.find({}).toArray(func); };
obj.StoreEvent = function (event) { obj.StoreEvent = function (event) {
checkObjectNames(event); // DEBUG CHECKING checkObjectNames(event, 'x5'); // DEBUG CHECKING
obj.eventsfile.insertOne(event); obj.eventsfile.insertOne(event);
}; };
obj.GetEvents = function (ids, domain, func) { obj.eventsfile.find({ domain: domain, ids: { $in: ids } }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).toArray(func); }; obj.GetEvents = function (ids, domain, func) { obj.eventsfile.find({ domain: domain, ids: { $in: ids } }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).toArray(func); };
@ -696,7 +696,7 @@ module.exports.CreateDB = function (parent, func) {
// Database actions on the power collection // Database actions on the power collection
obj.getAllPower = function (func) { obj.powerfile.find({}).toArray(func); }; obj.getAllPower = function (func) { obj.powerfile.find({}).toArray(func); };
obj.storePowerEvent = function (event, multiServer, func) { obj.storePowerEvent = function (event, multiServer, func) {
checkObjectNames(event); // DEBUG CHECKING checkObjectNames(event, 'x6'); // DEBUG CHECKING
if (multiServer != null) { event.server = multiServer.serverid; } obj.powerfile.insertOne(event, func); if (multiServer != null) { event.server = multiServer.serverid; } obj.powerfile.insertOne(event, func);
}; };
obj.getPowerTimeline = function (nodeid, func) { obj.powerfile.find({ nodeid: { $in: ['*', nodeid] } }).project({ _id: 0, nodeid: 0, s: 0 }).sort({ time: 1 }).toArray(func); }; obj.getPowerTimeline = function (nodeid, func) { obj.powerfile.find({ nodeid: { $in: ['*', nodeid] } }).project({ _id: 0, nodeid: 0, s: 0 }).sort({ time: 1 }).toArray(func); };
@ -705,7 +705,7 @@ module.exports.CreateDB = function (parent, func) {
// Database actions on the SMBIOS collection // Database actions on the SMBIOS collection
obj.SetSMBIOS = function (smbios, func) { obj.SetSMBIOS = function (smbios, func) {
checkObjectNames(smbios); // DEBUG CHECKING checkObjectNames(smbios, 'x7'); // DEBUG CHECKING
obj.smbiosfile.updateOne({ _id: smbios._id }, { $set: smbios }, { upsert: true }, func); obj.smbiosfile.updateOne({ _id: smbios._id }, { $set: smbios }, { upsert: true }, func);
}; };
obj.RemoveSMBIOS = function (id) { obj.smbiosfile.deleteOne({ _id: id }); }; obj.RemoveSMBIOS = function (id) { obj.smbiosfile.deleteOne({ _id: id }); };
@ -713,7 +713,7 @@ module.exports.CreateDB = function (parent, func) {
// Database actions on the Server Stats collection // Database actions on the Server Stats collection
obj.SetServerStats = function (data, func) { obj.SetServerStats = function (data, func) {
checkObjectNames(data); // DEBUG CHECKING checkObjectNames(data, 'x8'); // DEBUG CHECKING
obj.serverstatsfile.insertOne(data, func); obj.serverstatsfile.insertOne(data, func);
}; };
obj.GetServerStats = function (hours, func) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); obj.serverstatsfile.find({ time: { $gt: t } }, { _id: 0, cpu: 0 }).toArray(func); }; obj.GetServerStats = function (hours, func) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); obj.serverstatsfile.find({ time: { $gt: t } }, { _id: 0, cpu: 0 }).toArray(func); };
@ -743,7 +743,7 @@ module.exports.CreateDB = function (parent, func) {
} else { } else {
// Database actions on the main collection (NeDB and MongoJS) // Database actions on the main collection (NeDB and MongoJS)
obj.Set = function (data, func) { obj.Set = function (data, func) {
checkObjectNames(data); // DEBUG CHECKING checkObjectNames(data, 'x9'); // DEBUG CHECKING
var xdata = performTypedRecordEncrypt(data); var xdata = performTypedRecordEncrypt(data);
obj.file.update({ _id: xdata._id }, xdata, { upsert: true }, func); obj.file.update({ _id: xdata._id }, xdata, { upsert: true }, func);
}; };
@ -775,21 +775,21 @@ module.exports.CreateDB = function (parent, func) {
obj.RemoveAll = function (func) { obj.file.remove({}, { multi: true }, func); }; obj.RemoveAll = function (func) { obj.file.remove({}, { multi: true }, func); };
obj.RemoveAllOfType = function (type, func) { obj.file.remove({ type: type }, { multi: true }, func); }; obj.RemoveAllOfType = function (type, func) { obj.file.remove({ type: type }, { multi: true }, func); };
obj.InsertMany = function (data, func) { obj.InsertMany = function (data, func) {
checkObjectNames(data); // DEBUG CHECKING checkObjectNames(data, 'x10'); // DEBUG CHECKING
obj.file.insert(data, func); obj.file.insert(data, func);
}; };
obj.RemoveMeshDocuments = function (id) { obj.file.remove({ meshid: id }, { multi: true }); obj.file.remove({ _id: 'nt' + id }); }; obj.RemoveMeshDocuments = function (id) { obj.file.remove({ meshid: id }, { multi: true }); obj.file.remove({ _id: 'nt' + id }); };
obj.MakeSiteAdmin = function (username, domain) { obj.MakeSiteAdmin = function (username, domain) {
obj.Get('user/' + domain + '/' + username, function (err, docs) { obj.Get('user/' + domain + '/' + username, function (err, docs) {
if (docs.length == 1) { if (docs.length == 1) {
checkObjectNames(docs[0]); // DEBUG CHECKING checkObjectNames(docs[0], 'x11'); // DEBUG CHECKING
docs[0].siteadmin = 0xFFFFFFFF; obj.Set(docs[0]); docs[0].siteadmin = 0xFFFFFFFF; obj.Set(docs[0]);
} }
}); });
}; };
obj.DeleteDomain = function (domain, func) { obj.file.remove({ domain: domain }, { multi: true }, func); }; obj.DeleteDomain = function (domain, func) { obj.file.remove({ domain: domain }, { multi: true }, func); };
obj.SetUser = function (user) { obj.SetUser = function (user) {
checkObjectNames(user); // DEBUG CHECKING checkObjectNames(user, 'x12'); // DEBUG CHECKING
var u = Clone(user); if (u.subscriptions) { delete u.subscriptions; } obj.Set(u); var u = Clone(user); if (u.subscriptions) { delete u.subscriptions; } obj.Set(u);
}; };
obj.dispose = function () { for (var x in obj) { if (obj[x].close) { obj[x].close(); } delete obj[x]; } }; obj.dispose = function () { for (var x in obj) { if (obj[x].close) { obj[x].close(); } delete obj[x]; } };
@ -800,7 +800,7 @@ module.exports.CreateDB = function (parent, func) {
// Database actions on the events collection // Database actions on the events collection
obj.GetAllEvents = function (func) { obj.eventsfile.find({}, func); }; obj.GetAllEvents = function (func) { obj.eventsfile.find({}, func); };
obj.StoreEvent = function (event) { obj.StoreEvent = function (event) {
checkObjectNames(event); // DEBUG CHECKING checkObjectNames(event, 'x13'); // DEBUG CHECKING
obj.eventsfile.insert(event); obj.eventsfile.insert(event);
}; };
obj.GetEvents = function (ids, domain, func) { if (obj.databaseType == 1) { obj.eventsfile.find({ domain: domain, ids: { $in: ids } }, { _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).exec(func); } else { obj.eventsfile.find({ domain: domain, ids: { $in: ids } }, { type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }, func); } }; obj.GetEvents = function (ids, domain, func) { if (obj.databaseType == 1) { obj.eventsfile.find({ domain: domain, ids: { $in: ids } }, { _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).exec(func); } else { obj.eventsfile.find({ domain: domain, ids: { $in: ids } }, { type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }, func); } };
@ -827,7 +827,7 @@ module.exports.CreateDB = function (parent, func) {
// Database actions on the power collection // Database actions on the power collection
obj.getAllPower = function (func) { obj.powerfile.find({}, func); }; obj.getAllPower = function (func) { obj.powerfile.find({}, func); };
obj.storePowerEvent = function (event, multiServer, func) { obj.storePowerEvent = function (event, multiServer, func) {
checkObjectNames(event); // DEBUG CHECKING checkObjectNames(event, 'x14'); // DEBUG CHECKING
if (multiServer != null) { event.server = multiServer.serverid; } obj.powerfile.insert(event, func); if (multiServer != null) { event.server = multiServer.serverid; } obj.powerfile.insert(event, func);
}; };
obj.getPowerTimeline = function (nodeid, func) { if (obj.databaseType == 1) { obj.powerfile.find({ nodeid: { $in: ['*', nodeid] } }, { _id: 0, nodeid: 0, s: 0 }).sort({ time: 1 }).exec(func); } else { obj.powerfile.find({ nodeid: { $in: ['*', nodeid] } }, { _id: 0, nodeid: 0, s: 0 }).sort({ time: 1 }, func); } }; obj.getPowerTimeline = function (nodeid, func) { if (obj.databaseType == 1) { obj.powerfile.find({ nodeid: { $in: ['*', nodeid] } }, { _id: 0, nodeid: 0, s: 0 }).sort({ time: 1 }).exec(func); } else { obj.powerfile.find({ nodeid: { $in: ['*', nodeid] } }, { _id: 0, nodeid: 0, s: 0 }).sort({ time: 1 }, func); } };
@ -841,7 +841,7 @@ module.exports.CreateDB = function (parent, func) {
// Database actions on the Server Stats collection // Database actions on the Server Stats collection
obj.SetServerStats = function (data, func) { obj.SetServerStats = function (data, func) {
checkObjectNames(data); // DEBUG CHECKING checkObjectNames(data, 'x15'); // DEBUG CHECKING
obj.serverstatsfile.insert(data, func); obj.serverstatsfile.insert(data, func);
}; };
obj.GetServerStats = function (hours, func) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); obj.serverstatsfile.find({ time: { $gt: t } }, { _id: 0, cpu: 0 }, func); }; obj.GetServerStats = function (hours, func) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); obj.serverstatsfile.find({ time: { $gt: t } }, { _id: 0, cpu: 0 }, func); };

View File

@ -526,7 +526,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
if (adminUser.links == null) adminUser.links = {}; if (adminUser.links == null) adminUser.links = {};
adminUser.links[obj.dbMeshKey] = { rights: 0xFFFFFFFF }; adminUser.links[obj.dbMeshKey] = { rights: 0xFFFFFFFF };
db.SetUser(adminUser); db.SetUser(adminUser);
parent.parent.DispatchEvent(['*', obj.dbMeshKey, adminUser._id], obj, { etype: 'mesh', username: adminUser.name, meshid: obj.dbMeshKey, name: meshname, mtype: 2, desc: '', action: 'createmesh', links: links, msg: 'Mesh created: ' + obj.meshid, domain: domain.id }); parent.parent.DispatchEvent(['*', obj.dbMeshKey, adminUser._id], obj, { etype: 'mesh', username: adminUser.name, meshid: obj.dbMeshKey, name: meshname, mtype: 2, desc: '', action: 'createmesh', msg: 'Mesh created: ' + obj.meshid, domain: domain.id });
} }
} else { } else {
if ((mesh != null) && (mesh.deleted != null) && (mesh.links)) { if ((mesh != null) && (mesh.deleted != null) && (mesh.links)) {
@ -547,7 +547,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
} }
// Send out an event indicating this mesh was "created" // Send out an event indicating this mesh was "created"
parent.parent.DispatchEvent(ids, obj, { etype: 'mesh', meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'createmesh', links: mesh.links, msg: 'Mesh undeleted: ' + mesh._id, domain: domain.id }); parent.parent.DispatchEvent(ids, obj, { etype: 'mesh', meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'createmesh', msg: 'Mesh undeleted: ' + mesh._id, domain: domain.id });
// Mark the mesh as active // Mark the mesh as active
delete mesh.deleted; delete mesh.deleted;
@ -617,7 +617,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
adminUser.links[obj.meshid] = { rights: 0xFFFFFFFF }; adminUser.links[obj.meshid] = { rights: 0xFFFFFFFF };
//adminUser.subscriptions = parent.subscribe(adminUser._id, ws); //adminUser.subscriptions = parent.subscribe(adminUser._id, ws);
db.SetUser(user); db.SetUser(user);
parent.parent.DispatchEvent(['*', meshid, user._id], obj, { etype: 'mesh', username: user.name, meshid: obj.meshid, name: obj.meshid, mtype: 2, desc: '', action: 'createmesh', links: links, msg: 'Mesh created: ' + obj.meshid, domain: domain.id }); parent.parent.DispatchEvent(['*', meshid, user._id], obj, { etype: 'mesh', username: user.name, meshid: obj.meshid, name: obj.meshid, mtype: 2, desc: '', action: 'createmesh', msg: 'Mesh created: ' + obj.meshid, domain: domain.id });
} }
} }

View File

@ -1110,7 +1110,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (mesh.links[deluser._id] != null) { delete mesh.links[deluser._id]; parent.db.Set(common.escapeLinksFieldName(mesh)); } if (mesh.links[deluser._id] != null) { delete mesh.links[deluser._id]; parent.db.Set(common.escapeLinksFieldName(mesh)); }
// Notify mesh change // Notify mesh change
change = 'Removed user ' + deluser.name + ' from group ' + mesh.name; change = 'Removed user ' + deluser.name + ' from group ' + mesh.name;
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', msg: change, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(['*', mesh._id, deluser._id, user._id], obj, event); parent.parent.DispatchEvent(['*', mesh._id, deluser._id, user._id], obj, event);
} }
@ -1682,7 +1682,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
// Event the device group creation // Event the device group creation
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', links: links, msg: 'Device group created: ' + command.meshname, domain: domain.id }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', msg: 'Device group created: ' + command.meshname, domain: domain.id };
parent.parent.DispatchEvent(['*', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon. parent.parent.DispatchEvent(['*', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon.
try { ws.send(JSON.stringify({ action: 'createmesh', responseid: command.responseid, result: 'ok', meshid: meshid })); } catch (ex) { } try { ws.send(JSON.stringify({ action: 'createmesh', responseid: command.responseid, result: 'ok', meshid: meshid })); } catch (ex) { }
@ -1763,7 +1763,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if ((common.validateInt(command.consent) == true) && (command.consent != mesh.consent)) { if (change != '') change += ' and consent changed'; else change += 'Group "' + mesh.name + '" consent changed'; mesh.consent = command.consent; } if ((common.validateInt(command.consent) == true) && (command.consent != mesh.consent)) { if (change != '') change += ' and consent changed'; else change += 'Group "' + mesh.name + '" consent changed'; mesh.consent = command.consent; }
if (change != '') { if (change != '') {
db.Set(common.escapeLinksFieldName(mesh)); db.Set(common.escapeLinksFieldName(mesh));
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, flags: mesh.flags, consent: mesh.consent, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, flags: mesh.flags, consent: mesh.consent, action: 'meshchange', msg: change, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(['*', mesh._id, user._id], obj, event); parent.parent.DispatchEvent(['*', mesh._id, user._id], obj, event);
} }
@ -1808,7 +1808,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(common.escapeLinksFieldName(mesh)); db.Set(common.escapeLinksFieldName(mesh));
// Notify mesh change // Notify mesh change
var event = { etype: 'mesh', username: newuser.name, userid: command.userid, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Added user ' + newuser.name + ' to mesh ' + mesh.name, domain: domain.id }; var event = { etype: 'mesh', username: newuser.name, userid: command.userid, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', msg: 'Added user ' + newuser.name + ' to mesh ' + mesh.name, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(['*', mesh._id, user._id, newuserid], obj, event); parent.parent.DispatchEvent(['*', mesh._id, user._id, newuserid], obj, event);
removedCount++; removedCount++;
@ -1870,9 +1870,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify mesh change // Notify mesh change
var event; var event;
if (deluser != null) { if (deluser != null) {
event = { etype: 'mesh', username: user.name, userid: deluser.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Removed user ' + deluser.name + ' from group ' + mesh.name, domain: domain.id }; event = { etype: 'mesh', username: user.name, userid: deluser.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', msg: 'Removed user ' + deluser.name + ' from group ' + mesh.name, domain: domain.id };
} else { } else {
event = { etype: 'mesh', username: user.name, userid: (deluserid.split('/')[2]), meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Removed user ' + (deluserid.split('/')[2]) + ' from group ' + mesh.name, domain: domain.id }; event = { etype: 'mesh', username: user.name, userid: (deluserid.split('/')[2]), meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', msg: 'Removed user ' + (deluserid.split('/')[2]) + ' from group ' + mesh.name, domain: domain.id };
} }
parent.parent.DispatchEvent(['*', mesh._id, user._id, command.userid], obj, event); parent.parent.DispatchEvent(['*', mesh._id, user._id, command.userid], obj, event);
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'removemeshuser', responseid: command.responseid, result: 'ok' })); } catch (ex) { } } if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'removemeshuser', responseid: command.responseid, result: 'ok' })); } catch (ex) { } }
@ -1913,7 +1913,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(common.escapeLinksFieldName(mesh)); db.Set(common.escapeLinksFieldName(mesh));
var amtpolicy2 = common.Clone(amtpolicy); var amtpolicy2 = common.Clone(amtpolicy);
delete amtpolicy2.password; delete amtpolicy2.password;
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, amt: amtpolicy2, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, amt: amtpolicy2, action: 'meshchange', msg: change, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(['*', mesh._id, user._id], obj, event); parent.parent.DispatchEvent(['*', mesh._id, user._id], obj, event);

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.4.2-b", "version": "0.4.2-d",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -1229,7 +1229,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
if (mesh.links[userid] != null) { delete mesh.links[userid]; obj.db.Set(obj.common.escapeLinksFieldName(mesh)); } if (mesh.links[userid] != null) { delete mesh.links[userid]; obj.db.Set(obj.common.escapeLinksFieldName(mesh)); }
// Notify mesh change // Notify mesh change
var change = 'Removed user ' + user.name + ' from group ' + mesh.name; var change = 'Removed user ' + user.name + ' from group ' + mesh.name;
obj.parent.DispatchEvent(['*', mesh._id, user._id, userid], obj, { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id }); obj.parent.DispatchEvent(['*', mesh._id, user._id, userid], obj, { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', msg: change, domain: domain.id });
} }
} }
} }