Fixed server crash when adding unknown user to device group.

Ylian Saint-Hilaire committed Apr 5, 2020 at 17:44 UTC 85c0490bf6a7808c0973d6df0c62e65936d72e17
3 files changed +7 -6
meshuser.js
+3 -3
@@ -2438,11 +2438,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2438 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 };
2439 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.
2440 parent.parent.DispatchEvent(['*', mesh._id, user._id, newuserid], obj, event);
2441 - msgs.push("Added user " + newuser._id.split('/')[2]);
2441 + msgs.push("Added user " + newuserid.split('/')[2]);
2442 successCount++;
2443 } else {
2444 - msgs.push("Unknown user " + newuserid._id.split('/')[2]);
2445 - unknownUsers.push(newuserid);
2444 + msgs.push("Unknown user " + newuserid.split('/')[2]);
2445 + unknownUsers.push(newuserid.split('/')[2]);
2446 failCount++;
2447 }
2448 }
package.json
+2 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.5.1-e",
3 + "version": "0.5.1-g",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
@@ -20,6 +20,7 @@
20 "amt",
21 "bin",
22 "views",
23 + "emails",
24 "agents",
25 "public",
26 "translate",
views/default.handlebars
+2 -2
@@ -9115,7 +9115,7 @@
9115 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>';
9116 } else {
9117 var link = shortname, publiclink = '';
9118 - if (publicfolder) { publiclink = ' (<a style=cursor:pointer title="' + "Display public link" + '" onclick=\'return p5showPublicLink("' + (publicPath + '/' + encodeURIComponent(f.nx)) + '")\'>' + "Link" + '</a>)'; }
9118 + 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>'; }
9119 if (f.s > 0) { link = '<a rel="noreferrer noopener" target="_blank" download href="downloadfile.ashx?link=' + encodeURIComponent(filetreelinkpath + '/' + f.nx) + '">' + shortname + '</a>' + publiclink; }
9120 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>';
9121 }
@@ -9166,7 +9166,7 @@
9166 }
9167
9168 function p5showPublicLink(u) {
9169 - setDialogMode(2, "Public Link", 1, null, '<input type=text style=width:100% value="' + u + '" readonly />');
9169 + 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>');
9170 return false;
9171 }
9172