Fixed server crash when adding unknown user to device group.

This commit is contained in:
Ylian Saint-Hilaire 2020-04-05 17:44:54 -07:00
parent 0225fe979b
commit df18c598ec
3 changed files with 7 additions and 6 deletions

View File

@ -2438,11 +2438,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var event = { etype: 'mesh', username: newuser.name, userid: user._id, 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, invite: mesh.invite };
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);
msgs.push("Added user " + newuser._id.split('/')[2]);
msgs.push("Added user " + newuserid.split('/')[2]);
successCount++;
} else {
msgs.push("Unknown user " + newuserid._id.split('/')[2]);
unknownUsers.push(newuserid);
msgs.push("Unknown user " + newuserid.split('/')[2]);
unknownUsers.push(newuserid.split('/')[2]);
failCount++;
}
}

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.5.1-e",
"version": "0.5.1-g",
"keywords": [
"Remote Management",
"Intel AMT",
@ -20,6 +20,7 @@
"amt",
"bin",
"views",
"emails",
"agents",
"public",
"translate",

View File

@ -9115,7 +9115,7 @@
h = '<div class=filelist file=999><input file=999 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value="' + name + '">&nbsp;<span style=float:right title=\"' + title + '\">' + right + '</span><span><div class=fileIcon' + f.t + ' onclick=p5folderset(\"' + encodeURIComponent(f.nx) + '\")></div><a href=# style=cursor:pointer onclick=\'return p5folderset(\"' + encodeURIComponent(f.nx) + '\")\'>' + shortname + '</a></span></div>';
} else {
var link = shortname, publiclink = '';
if (publicfolder) { publiclink = ' (<a style=cursor:pointer title="' + "Display public link" + '" onclick=\'return p5showPublicLink("' + (publicPath + '/' + encodeURIComponent(f.nx)) + '")\'>' + "Link" + '</a>)'; }
if (publicfolder) { publiclink = ' <img src="images/link2.png" style=cursor:pointer title="' + "Display public link" + '" onclick=\'return p5showPublicLink("' + (publicPath + '/' + encodeURIComponent(f.nx)) + '")\' width=10 height=10 /> <img src="images/link4.png" title="' + "Copy link to clipboard" + '" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(publicPath + '/' + encodeURIComponent(f.nx)) + '\") width=10 height=10>'; }
if (f.s > 0) { link = '<a rel="noreferrer noopener" target="_blank" download href="downloadfile.ashx?link=' + encodeURIComponent(filetreelinkpath + '/' + f.nx) + '">' + shortname + '</a>' + publiclink; }
h = '<div class=filelist file=3><input file=3 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value="' + f.nx + '">&nbsp;<span class=fsize>' + fdatestr + '</span><span style=float:right>' + fsize + '</span><span><div class=fileIcon' + f.t + '></div>' + link + '</span></div>';
}
@ -9166,7 +9166,7 @@
}
function p5showPublicLink(u) {
setDialogMode(2, "Public Link", 1, null, '<input type=text style=width:100% value="' + u + '" readonly />');
setDialogMode(2, "Public Link", 1, null, '<input type=text style=width:350px value="' + u + '" readonly /> <img src="images/link4.png" title="' + "Copy link to clipboard" + '" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(u) + '\") width=10 height=10>');
return false;
}