mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-22 21:31:35 +03:00
Added user account real name support.
This commit is contained in:
parent
19bfa7a8a1
commit
4b10e225dd
@ -712,6 +712,7 @@ function createMeshCore(agent) {
|
||||
tunnel.consent = data.consent;
|
||||
tunnel.privacybartext = data.privacybartext ? data.privacybartext : "Sharing desktop with: {0}";
|
||||
tunnel.username = data.username;
|
||||
tunnel.realname = data.realname ? data.realname : data.username;
|
||||
tunnel.userid = data.userid;
|
||||
tunnel.remoteaddr = data.remoteaddr;
|
||||
tunnel.state = 0;
|
||||
@ -1624,10 +1625,10 @@ function createMeshCore(agent) {
|
||||
};
|
||||
if (this.httprequest.desktop.kvm.hasOwnProperty('connectionCount')) {
|
||||
this.httprequest.desktop.kvm.connectionCount++;
|
||||
this.httprequest.desktop.kvm.users.push(this.httprequest.username);
|
||||
this.httprequest.desktop.kvm.users.push(this.httprequest.realname);
|
||||
} else {
|
||||
this.httprequest.desktop.kvm.connectionCount = 1;
|
||||
this.httprequest.desktop.kvm.users = [this.httprequest.username];
|
||||
this.httprequest.desktop.kvm.users = [this.httprequest.realname];
|
||||
}
|
||||
|
||||
if ((this.httprequest.rights == 0xFFFFFFFF) || (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) != 0) && ((this.httprequest.rights & MESHRIGHT_REMOTEVIEW) == 0))) {
|
||||
@ -1645,10 +1646,10 @@ function createMeshCore(agent) {
|
||||
// User Consent Prompt is required
|
||||
// Send a console message back using the console channel, "\n" is supported.
|
||||
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: "Waiting for user to grant access...", msgid: 1 }));
|
||||
var consentMessage = this.httprequest.username + " requesting remote desktop access. Grant access?", consentTitle = 'MeshCentral';
|
||||
var consentMessage = this.httprequest.realname + " requesting remote desktop access. Grant access?", consentTitle = 'MeshCentral';
|
||||
if (this.httprequest.soptions != null) {
|
||||
if (this.httprequest.soptions.consentTitle != null) { consentTitle = this.httprequest.soptions.consentTitle; }
|
||||
if (this.httprequest.soptions.consentMsgDesktop != null) { consentMessage = this.httprequest.soptions.consentMsgDesktop.replace('{0}', this.httprequest.username); }
|
||||
if (this.httprequest.soptions.consentMsgDesktop != null) { consentMessage = this.httprequest.soptions.consentMsgDesktop.replace('{0}', this.httprequest.realname); }
|
||||
}
|
||||
var pr = require('message-box').create(consentTitle, consentMessage, 30, null, tsid);
|
||||
pr.ws = this;
|
||||
@ -1664,10 +1665,10 @@ function createMeshCore(agent) {
|
||||
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null, msgid: 0 }));
|
||||
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1)) {
|
||||
// User Notifications is required
|
||||
var notifyMessage = this.ws.httprequest.username + " started a remote desktop session.", notifyTitle = "MeshCentral";
|
||||
var notifyMessage = this.ws.httprequest.realname + " started a remote desktop session.", notifyTitle = "MeshCentral";
|
||||
if (this.ws.httprequest.soptions != null) {
|
||||
if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
|
||||
if (this.ws.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.ws.httprequest.username); }
|
||||
if (this.ws.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.ws.httprequest.realname); }
|
||||
}
|
||||
try { require('toaster').Toast(notifyTitle, notifyMessage, tsid); } catch (ex) { }
|
||||
}
|
||||
@ -1713,10 +1714,10 @@ function createMeshCore(agent) {
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 1)) {
|
||||
// User Notifications is required
|
||||
MeshServerLog("Started remote desktop with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
|
||||
var notifyMessage = this.httprequest.username + " started a remote desktop session.", notifyTitle = "MeshCentral";
|
||||
var notifyMessage = this.httprequest.realname + " started a remote desktop session.", notifyTitle = "MeshCentral";
|
||||
if (this.httprequest.soptions != null) {
|
||||
if (this.httprequest.soptions.notifyTitle != null) { notifyTitle = this.httprequest.soptions.notifyTitle; }
|
||||
if (this.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.httprequest.username); }
|
||||
if (this.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.httprequest.realname); }
|
||||
}
|
||||
try { require('toaster').Toast(notifyTitle, notifyMessage, tsid); } catch (ex) { }
|
||||
} else {
|
||||
@ -1789,10 +1790,10 @@ function createMeshCore(agent) {
|
||||
// User Consent Prompt is required
|
||||
// Send a console message back using the console channel, "\n" is supported.
|
||||
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: "Waiting for user to grant access...", msgid: 1 }));
|
||||
var consentMessage = this.httprequest.username + " requesting remote file Access. Grant access?", consentTitle = 'MeshCentral';
|
||||
var consentMessage = this.httprequest.realname + " requesting remote file Access. Grant access?", consentTitle = 'MeshCentral';
|
||||
if (this.httprequest.soptions != null) {
|
||||
if (this.httprequest.soptions.consentTitle != null) { consentTitle = this.httprequest.soptions.consentTitle; }
|
||||
if (this.httprequest.soptions.consentMsgFiles != null) { consentMessage = this.httprequest.soptions.consentMsgFiles.replace('{0}', this.httprequest.username); }
|
||||
if (this.httprequest.soptions.consentMsgFiles != null) { consentMessage = this.httprequest.soptions.consentMsgFiles.replace('{0}', this.httprequest.realname); }
|
||||
}
|
||||
var pr = require('message-box').create(consentTitle, consentMessage, 30);
|
||||
pr.ws = this;
|
||||
@ -1808,10 +1809,10 @@ function createMeshCore(agent) {
|
||||
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
|
||||
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4)) {
|
||||
// User Notifications is required
|
||||
var notifyMessage = this.ws.httprequest.username + " started a remote file session.", notifyTitle = "MeshCentral";
|
||||
var notifyMessage = this.ws.httprequest.realname + " started a remote file session.", notifyTitle = "MeshCentral";
|
||||
if (this.ws.httprequest.soptions != null) {
|
||||
if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
|
||||
if (this.ws.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgFiles.replace('{0}', this.ws.httprequest.username); }
|
||||
if (this.ws.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgFiles.replace('{0}', this.ws.httprequest.realname); }
|
||||
}
|
||||
try { require('toaster').Toast(notifyTitle, notifyMessage); } catch (ex) { }
|
||||
}
|
||||
@ -1829,10 +1830,10 @@ function createMeshCore(agent) {
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 4)) {
|
||||
// User Notifications is required
|
||||
MeshServerLog("Started remote files with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
|
||||
var notifyMessage = this.httprequest.username + " started a remote file session.", notifyTitle = "MeshCentral";
|
||||
var notifyMessage = this.httprequest.realname + " started a remote file session.", notifyTitle = "MeshCentral";
|
||||
if (this.httprequest.soptions != null) {
|
||||
if (this.httprequest.soptions.notifyTitle != null) { notifyTitle = this.httprequest.soptions.notifyTitle; }
|
||||
if (this.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.httprequest.soptions.notifyMsgFiles.replace('{0}', this.httprequest.username); }
|
||||
if (this.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.httprequest.soptions.notifyMsgFiles.replace('{0}', this.httprequest.realname); }
|
||||
}
|
||||
try { require('toaster').Toast(notifyTitle, notifyMessage); } catch (ex) { }
|
||||
} else {
|
||||
|
@ -159,14 +159,16 @@
|
||||
"skip2factor": { "type": "string" }
|
||||
}
|
||||
},
|
||||
"agentInviteCodes": { "type": "boolean", "default": false },
|
||||
"agentNoProxy": { "type": "boolean", "default": false },
|
||||
"geoLocation": { "type": "boolean", "default": false },
|
||||
"novnc": { "type": "boolean", "default": true },
|
||||
"mstsc": { "type": "boolean", "default": false },
|
||||
"agentInviteCodes": { "type": "boolean", "default": false, "description": "Enabled a feature where you can set one or more invitation codes in a device group. You can then give a invitation link to users who can use it to download the agent." },
|
||||
"agentNoProxy": { "type": "boolean", "default": false, "description": "When enabled, all newly installed MeshAgents will be instructed to no use a HTTP/HTTPS proxy even if one is configured on the remote system" },
|
||||
"geoLocation": { "type": "boolean", "default": false, "description": "Enables the geo-location feature and device location map in the user interface, this feature is not being worked on." },
|
||||
"novnc": { "type": "boolean", "default": true, "description": "When enabled, activates the built-in web-based noVNC client." },
|
||||
"mstsc": { "type": "boolean", "default": false, "description": "When enabled, activates the built-in web-based RDP client." },
|
||||
"webEmailsPath": { "type": "string", "description": "Path where to find custom email templates for this domain." },
|
||||
"customUI": { "type": "object" },
|
||||
"consentMessages": {
|
||||
"type": "object",
|
||||
"description": "This section is user to customize user consent prompts, these show up when asking if a remote session is allowed or not.",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"Title": { "type": "string" },
|
||||
@ -178,6 +180,7 @@
|
||||
"notificationMessages": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "This section is user to customize user notifications when a remote desktop, terminal or file session is connected to a remote system.",
|
||||
"properties": {
|
||||
"Title": { "type": "string" },
|
||||
"Desktop": { "type": "string" },
|
||||
|
@ -888,6 +888,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||
command.consent = mesh.consent; // Add user consent
|
||||
if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
|
||||
command.username = user.name; // Add user name
|
||||
command.realname = user.realname; // Add real name
|
||||
if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text
|
||||
delete command.nodeid; // Remove the nodeid since it's implyed.
|
||||
agent.send(JSON.stringify(command));
|
||||
@ -906,6 +907,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||
command.consent = mesh.consent; // Add user consent
|
||||
if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
|
||||
command.username = user.name; // Add user name
|
||||
command.realname = user.realname; // Add real name
|
||||
if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text
|
||||
parent.parent.multiServer.DispatchMessageSingleServer(command, routing.serverid);
|
||||
return true;
|
||||
|
@ -95,6 +95,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||
command.consent = mesh.consent; // Add user consent
|
||||
if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
|
||||
command.username = user.name; // Add user name
|
||||
command.realname = user.realname; // Add real name
|
||||
if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text
|
||||
delete command.nodeid; // Remove the nodeid since it's implyed.
|
||||
agent.send(JSON.stringify(command));
|
||||
@ -113,6 +114,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||
command.consent = mesh.consent; // Add user consent
|
||||
if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
|
||||
command.username = user.name; // Add user name
|
||||
command.realname = user.realname; // Add real name
|
||||
if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text
|
||||
parent.parent.multiServer.DispatchMessageSingleServer(command, routing.serverid);
|
||||
return true;
|
||||
|
17
meshuser.js
17
meshuser.js
@ -195,8 +195,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if (typeof node.consent == 'number') { command.consent |= node.consent; } // Add node user consent
|
||||
if (typeof user.consent == 'number') { command.consent |= user.consent; } // Add user consent
|
||||
command.username = user.name; // Add user name
|
||||
command.realname = user.realname; // Add real name
|
||||
command.userid = user._id; // Add user id
|
||||
command.remoteaddr = req.clientIp; // User's IP address
|
||||
command.remoteaddr = req.clientIp; // User's IP address
|
||||
if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text
|
||||
delete command.nodeid; // Remove the nodeid since it's implied
|
||||
try { agent.send(JSON.stringify(command)); } catch (ex) { }
|
||||
@ -218,8 +219,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if (typeof node.consent == 'number') { command.consent |= node.consent; } // Add node user consent
|
||||
if (typeof user.consent == 'number') { command.consent |= user.consent; } // Add user consent
|
||||
command.username = user.name; // Add user name
|
||||
command.realname = user.realname; // Add real name
|
||||
command.userid = user._id; // Add user id
|
||||
command.remoteaddr = req.clientIp; // User's IP address
|
||||
command.remoteaddr = req.clientIp; // User's IP address
|
||||
if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text
|
||||
parent.parent.multiServer.DispatchMessageSingleServer(command, routing.serverid);
|
||||
}
|
||||
@ -1835,7 +1837,16 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
// Validate and change email
|
||||
if (edituserdomain.usernameisemail !== true) {
|
||||
if (common.validateString(command.email, 1, 1024) && (chguser.email != command.email)) { chguser.email = command.email.toLowerCase(); change = 1; }
|
||||
if (common.validateString(command.email, 1, 1024) && (chguser.email != command.email)) {
|
||||
if (command.email == '') { delete chguser.email; } else { chguser.email = command.email.toLowerCase(); }
|
||||
change = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate and change realm name
|
||||
if (common.validateString(command.realname, 1, 256) && (chguser.realname != command.realname)) {
|
||||
if (command.realname == '') { delete chguser.realname; } else { chguser.realname = command.realname; }
|
||||
change = 1;
|
||||
}
|
||||
|
||||
// Make changes
|
||||
|
@ -140,6 +140,7 @@
|
||||
"_geoLocation": true,
|
||||
"_novnc": false,
|
||||
"_mstsc": true,
|
||||
"_WebEmailsPath": "/myserver/email-templates",
|
||||
"_consentMessages": {
|
||||
"title": "MeshCentral",
|
||||
"desktop": "{0} requesting remote desktop access. Grant access?",
|
||||
|
@ -11349,6 +11349,7 @@
|
||||
var x = '<div style=min-height:80px><table style=width:100%>';
|
||||
if ((args.hide & 8) != 0) { x += '<br />' + addDeviceAttribute("Name", user.name); } // If title bar is hidden, display the user name here
|
||||
var email = user.email?EscapeHtml(user.email):'<i>' + "Not set" + '</i>', everify = '';
|
||||
var realname = user.realname?EscapeHtml(user.realname):'<i>' + "Not set" + '</i>';
|
||||
if (serverinfo.emailcheck) { everify = ((user.emailVerified == true) ? '<b style=color:green;cursor:pointer title="' + "Email is verified" + '">✓</b> ' : '<b style=color:red;cursor:pointer title="' + "Email not verified" + '">✗</b> '); }
|
||||
|
||||
if ((serverinfo.crossDomain) || (debugmode != 0)) {
|
||||
@ -11359,10 +11360,12 @@
|
||||
if (user.name.toLowerCase() != user._id.split('/')[2]) { x += addDeviceAttribute("User Identifier", EscapeHtml(user._id.split('/')[2])); }
|
||||
}
|
||||
|
||||
if (((user.siteadmin != 0xFFFFFFFF) || (userinfo.siteadmin == 0xFFFFFFFF))) { // If we are not site admin, we can't change a admin email.
|
||||
if (((user.siteadmin != 0xFFFFFFFF) || (userinfo.siteadmin == 0xFFFFFFFF))) { // If we are not site admin, we can't change a admin email or real name
|
||||
x += addDeviceAttribute("Email", everify + email + ' <a href="mailto:' + EscapeHtml(user.email) + '" \'><img class=hoverButton src="images/link1.png" /></a>' + ' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserEmailChangeDialog(event,"' + userid + '") />');
|
||||
x += addDeviceAttribute("Real Name", realname + ' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserRealNameChangeDialog(event,"' + userid + '") />');
|
||||
} else {
|
||||
x += addDeviceAttribute("Email", everify + email + ' <a href="mailto:' + EscapeHtml(user.email) + '" \'><img class=hoverButton src="images/link1.png" /></a>');
|
||||
x += addDeviceAttribute("Real Name", realname);
|
||||
}
|
||||
|
||||
if ((features & 0x02000000) || (user.phone != null)) { // If SMS is enabled on the server or user has a phone number
|
||||
@ -11483,6 +11486,22 @@
|
||||
// Send to the server the user's new phone number
|
||||
function p30editPhoneEx() { meshserver.send({ action: 'edituser', id: currentUser._id, phone: Q('d2phoneinput').value }); }
|
||||
|
||||
// Display the user's real name change dialog box
|
||||
function p30showUserRealNameChangeDialog(event) {
|
||||
if (xxdialogMode) return false;
|
||||
var x = '';
|
||||
x += addHtmlValue("Real Name", '<input id=dp30realname style=width:230px maxlength=256 />');
|
||||
setDialogMode(2, format("Change Real Name for {0}", EscapeHtml(currentUser.name)), 3, p30showUserRealNameChangeDialogEx, x);
|
||||
Q('dp30realname').focus();
|
||||
Q('dp30realname').value = (currentUser.realname?currentUser.realname:'');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send to the server the new user's real name
|
||||
function p30showUserRealNameChangeDialogEx() {
|
||||
meshserver.send({ action: 'edituser', id: currentUser._id, realname: Q('dp30realname').value });
|
||||
}
|
||||
|
||||
// Display the user's email change dialog box
|
||||
function p30showUserEmailChangeDialog(event) {
|
||||
if (xxdialogMode) return false;
|
||||
|
Loading…
Reference in New Issue
Block a user