Fixed device chat permissions.

This commit is contained in:
Ylian Saint-Hilaire 2019-10-15 16:26:24 -07:00
parent c70d755854
commit 51095271de
2 changed files with 23 additions and 11 deletions

View File

@ -1567,11 +1567,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
} }
case 'meshmessenger': case 'meshmessenger':
{ {
// Send a notification message to a user
if ((user.siteadmin & 2) == 0) break;
// Setup a user-to-user session // Setup a user-to-user session
if (common.validateString(command.userid, 1, 2048)) { if (common.validateString(command.userid, 1, 2048)) {
// Send a notification message to a user
if ((user.siteadmin & 2) == 0) break;
// Can only perform this operation on other users of our group. // Can only perform this operation on other users of our group.
var chguser = parent.users[command.userid]; var chguser = parent.users[command.userid];
@ -1596,6 +1595,17 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (common.validateString(command.nodeid, 1, 2048)) { if (common.validateString(command.nodeid, 1, 2048)) {
if (args.lanonly == true) { return; } // User-to-device chat is not support in LAN-only mode yet. We need the agent to replace the IP address of the server?? if (args.lanonly == true) { return; } // User-to-device chat is not support in LAN-only mode yet. We need the agent to replace the IP address of the server??
// Get the device
db.Get(command.nodeid, function (err, nodes) {
if ((nodes == null) || (nodes.length != 1)) return;
var node = nodes[0];
// Get the mesh for this device
mesh = parent.meshes[node.meshid];
if (mesh) {
// Check if this user has rights to do this
if (mesh.links[user._id] == null || ((mesh.links[user._id].rights & MESHRIGHT_REMOTECONTROL) == 0)) return;
// Create the server url // Create the server url
var httpsPort = ((args.aliasport == null) ? args.port : args.aliasport); // Use HTTPS alias port is specified var httpsPort = ((args.aliasport == null) ? args.port : args.aliasport); // Use HTTPS alias port is specified
var xdomain = (domain.dns == null) ? domain.id : ''; var xdomain = (domain.dns == null) ? domain.id : '';
@ -1605,6 +1615,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Create the notification message // Create the notification message
routeCommandToNode({ "action": "openUrl", "nodeid": command.nodeid, "userid": user._id, "username": user.name, "url": url }); routeCommandToNode({ "action": "openUrl", "nodeid": command.nodeid, "userid": user._id, "username": user.name, "url": url });
} }
});
}
break; break;
} }

View File

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