This commit is contained in:
Ylian Saint-Hilaire 2021-04-08 10:12:08 -07:00
parent 46622192e8
commit 2ded4c60d5

View File

@ -4216,9 +4216,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
{
// Check if this user has rights on this nodeid
if (common.validateString(command.nodeid, 1, 1024) == false) break; // Check nodeid
db.Get(command.nodeid, function (err, nodes) { // TODO: Make a NodeRights(user) method that also does not do a db call if agent is connected (???)
if ((err == null) && (nodes.length == 1)) {
if ((parent.GetMeshRights(user, nodes[0].meshid) & MESHRIGHT_REMOTECONTROL) != 0) {
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
if ((node == null) || ((rights & MESHRIGHT_REMOTECONTROL) == 0) || (visible == false)) return; // Access denied.
// Add a user authentication cookie to a url
var cookieContent = { userid: user._id, domainid: user.domain };
if (command.nodeid) { cookieContent.nodeid = command.nodeid; }
@ -4228,8 +4228,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
command.cookie = parent.parent.encodeCookie(cookieContent, parent.parent.loginCookieEncryptionKey);
command.trustedCert = parent.isTrustedCert(domain);
try { ws.send(JSON.stringify(command)); } catch (ex) { }
}
}
});
break;
}