Improved user management page.

This commit is contained in:
Ylian Saint-Hilaire 2019-03-01 11:47:58 -08:00
parent cc1ab15d43
commit e118075a08
6 changed files with 44 additions and 32 deletions

View File

@ -31,6 +31,9 @@ var MESHRIGHT_SERVERFILES = 32;
var MESHRIGHT_WAKEDEVICE = 64; var MESHRIGHT_WAKEDEVICE = 64;
var MESHRIGHT_SETNOTES = 128; var MESHRIGHT_SETNOTES = 128;
var MESHRIGHT_REMOTEVIEW = 256; var MESHRIGHT_REMOTEVIEW = 256;
var MESHRIGHT_NOTERMINAL = 512;
var MESHRIGHT_NOFILES = 1024;
var MESHRIGHT_NOAMT = 2048;
function createMeshCore(agent) { function createMeshCore(agent) {
var obj = {}; var obj = {};
@ -683,16 +686,17 @@ function createMeshCore(agent) {
if (data == 'c') { this.httprequest.state = 1; /*sendConsoleText("Tunnel #" + this.httprequest.index + " now active", this.httprequest.sessionid);*/ } if (data == 'c') { this.httprequest.state = 1; /*sendConsoleText("Tunnel #" + this.httprequest.index + " now active", this.httprequest.sessionid);*/ }
} else { } else {
// Handle tunnel data // Handle tunnel data
if (this.httprequest.protocol == 0) { // 1 = SOL, 2 = KVM, 3 = IDER, 4 = Files, 5 = FileTransfer if (this.httprequest.protocol == 0) { // 1 = Terminal, 2 = Desktop, 5 = Files
// Take a look at the protocol // Take a look at the protocol
this.httprequest.protocol = parseInt(data); this.httprequest.protocol = parseInt(data);
if (typeof this.httprequest.protocol != 'number') { this.httprequest.protocol = 0; } if (typeof this.httprequest.protocol != 'number') { this.httprequest.protocol = 0; }
if (this.httprequest.protocol == 1) { if (this.httprequest.protocol == 1) {
// Check user access rights // Check user access rights for terminal
if ((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) { if (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) || ((this.httprequest.rights != 0xFFFFFFFF) && ((this.httprequest.rights & MESHRIGHT_NOTERMINAL) != 0))) {
// Disengage this tunnel, user does not have the rights to do this!! // Disengage this tunnel, user does not have the rights to do this!!
this.httprequest.protocol = 999999; this.httprequest.protocol = 999999;
sendConsoleText('Error: No Remote Control Rights.'); this.httprequest.s.end();
sendConsoleText('Error: No Terminal Control Rights.');
return; return;
} }
@ -740,11 +744,12 @@ function createMeshCore(agent) {
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nclear\n"); } if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nclear\n"); }
} else if (this.httprequest.protocol == 2) } else if (this.httprequest.protocol == 2)
{ {
// Check user access rights // Check user access rights for desktop
if (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) && ((this.httprequest.rights & MESHRIGHT_REMOTEVIEW) == 0)) { if (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) && ((this.httprequest.rights & MESHRIGHT_REMOTEVIEW) == 0)) {
// Disengage this tunnel, user does not have the rights to do this!! // Disengage this tunnel, user does not have the rights to do this!!
this.httprequest.protocol = 999999; this.httprequest.protocol = 999999;
sendConsoleText('Error: No Remote Control Rights.'); this.httprequest.s.end();
sendConsoleText('Error: No Desktop Control Rights.');
return; return;
} }
@ -791,11 +796,12 @@ function createMeshCore(agent) {
this.on('data', onTunnelControlData); this.on('data', onTunnelControlData);
//this.write('MeshCore KVM Hello!1'); //this.write('MeshCore KVM Hello!1');
} else if (this.httprequest.protocol == 5) { } else if (this.httprequest.protocol == 5) {
// Check user access rights // Check user access rights for files
if ((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) { if (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) || ((this.httprequest.rights != 0xFFFFFFFF) && ((this.httprequest.rights & MESHRIGHT_NOFILES) != 0))) {
// Disengage this tunnel, user does not have the rights to do this!! // Disengage this tunnel, user does not have the rights to do this!!
this.httprequest.protocol = 999999; this.httprequest.protocol = 999999;
sendConsoleText('Error: No Remote Control Rights.'); this.httprequest.s.end();
sendConsoleText('Error: No Files Control Rights.');
return; return;
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.2.9-j", "version": "0.2.9-l",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1873,7 +1873,7 @@
var menus = []; var menus = [];
if (currentDevicePanel != 0) { menus.push({ n: 'General', f: 'setupDeviceMenu(0)' }); } if (currentDevicePanel != 0) { menus.push({ n: 'General', f: 'setupDeviceMenu(0)' }); }
if ((currentDevicePanel != 1) && (currentNode != null) && ((meshrights & 8) || (meshrights & 256)) && ((currentNode.mtype == 1) || (currentNode.agent.caps & 1))) { menus.push({ n: 'Desktop', f: 'setupDeviceMenu(1)' }); } if ((currentDevicePanel != 1) && (currentNode != null) && ((meshrights & 8) || (meshrights & 256)) && ((currentNode.mtype == 1) || (currentNode.agent.caps & 1))) { menus.push({ n: 'Desktop', f: 'setupDeviceMenu(1)' }); }
if ((currentDevicePanel != 2) && (currentNode != null) && (meshrights & 8) && ((currentNode.mtype == 2) && (currentNode.agent.caps & 4))) { menus.push({ n: 'Files', f: 'setupDeviceMenu(2)' }); } if ((currentDevicePanel != 2) && (currentNode != null) && (meshrights & 8) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0)) && ((currentNode.mtype == 2) && (currentNode.agent.caps & 4))) { menus.push({ n: 'Files', f: 'setupDeviceMenu(2)' }); }
updateFooterMenu(menus); updateFooterMenu(menus);
} }

View File

@ -6358,13 +6358,16 @@
// Display the users using the sorted list // Display the users using the sorted list
var x = '<table style=width:100% cellpadding=0 cellspacing=0>', addHeader = true; var x = '<table style=width:100% cellpadding=0 cellspacing=0>', addHeader = true;
x += '<th style=color:gray>Name<th style=color:gray>Groups<th style=color:gray>Last Access<th style=color:gray>Permissions';
// Online users // Online users
for (var i in sortedUserIds) { for (var i in sortedUserIds) {
var user = users[sortedUserIds[i]], sessions = null; var user = users[sortedUserIds[i]], sessions = null;
if (wssessions != null) { sessions = wssessions[user._id]; } if (wssessions != null) { sessions = wssessions[user._id]; }
if ((sessions != null) && (user.name.toLowerCase().indexOf(userSearch) >= 0)) { if ((sessions != null) && (user.name.toLowerCase().indexOf(userSearch) >= 0)) {
if (maxUsers > 0) { if (maxUsers > 0) {
if (addHeader) { x += '<tr><td class=userTableHeader>Online Users'; addHeader = false; } if (addHeader) { x += '<tr><td class=userTableHeader colspan=4>Online Users'; addHeader = false; }
x += addUserHtml(user, sessions); x += addUserHtml(user, sessions);
maxUsers--; maxUsers--;
} else { } else {
@ -6379,7 +6382,7 @@
if (wssessions != null) { sessions = wssessions[user._id]; } if (wssessions != null) { sessions = wssessions[user._id]; }
if ((sessions == null) && (user.name.toLowerCase().indexOf(userSearch) >= 0)) { if ((sessions == null) && (user.name.toLowerCase().indexOf(userSearch) >= 0)) {
if (maxUsers > 0) { if (maxUsers > 0) {
if (addHeader) { x += '<tr><td class=userTableHeader>Offline Users'; addHeader = false; } if (addHeader) { x += '<tr><td class=userTableHeader colspan=4>Offline Users'; addHeader = false; }
x += addUserHtml(user, sessions); x += addUserHtml(user, sessions);
maxUsers--; maxUsers--;
} else { } else {
@ -6398,33 +6401,36 @@
} }
function addUserHtml(user, sessions) { function addUserHtml(user, sessions) {
var x = '', gray = ' gray', icon = 'm2', msg = '', msg2 = '', self = (user.name != userinfo.name); var x = '', gray = ' gray', icon = 'm2', msg = '', self = (user.name != userinfo.name), lastAccess = '', permissions = '';
if (sessions != null) { if (sessions != null) {
gray = ''; gray = '';
if (self) { if (self) {
msg2 = "<span style=float:right;margin-top:1px;margin-right:4px title=Chat><a onclick=userChat(event,\"" + encodeURIComponent(user._id) + "\",\"" + encodeURIComponent(user.name) + "\")><img src='images/icon-chat.png' height=16 width=16 style=padding-top:2px /></a></span>"; msg = "<span style=float:right;margin-top:1px;margin-right:4px title=Chat><a onclick=userChat(event,\"" + encodeURIComponent(user._id) + "\",\"" + encodeURIComponent(user.name) + "\")><img src='images/icon-chat.png' height=16 width=16 style=padding-top:2px /></a></span>";
msg2 += "<span style=float:right;margin-top:1px;margin-left:4px;margin-right:4px title=Notify><a onclick=showUserAlertDialog(event,\"" + encodeURIComponent(user._id) + "\")><img src='images/icon-notify.png' height=16 width=16 style=padding-top:2px /></a></span>"; msg += "<span style=float:right;margin-top:1px;margin-left:4px;margin-right:4px title=Notify><a onclick=showUserAlertDialog(event,\"" + encodeURIComponent(user._id) + "\")><img src='images/icon-notify.png' height=16 width=16 style=padding-top:2px /></a></span>";
} }
if (sessions == 1) { msg += '1 active session'; } else { msg += sessions + ' active sessions'; } if (sessions == 1) { lastAccess += '1 session'; } else { lastAccess += sessions + ' sessions'; }
} else { } else {
if (user.login) { msg += '<span title="Last login: ' + new Date(user.login * 1000).toLocaleString() + '">' + new Date(user.login * 1000).toLocaleDateString() + '</span>'; } if (user.login) { lastAccess += '<span title="Last login: ' + new Date(user.login * 1000).toLocaleString() + '">' + new Date(user.login * 1000).toLocaleDateString() + '</span>'; }
} }
if (msg != '') msg += ', '; if (self) { permissions += "<a style=cursor:pointer onclick=showUserAdminDialog(event,\"" + encodeURIComponent(user._id) + "\")>"; }
if (self) { msg += "<a onclick=showUserAdminDialog(event,\"" + encodeURIComponent(user._id) + "\")>"; } if ((user.siteadmin != null) && ((user.siteadmin & 32) != 0) && (user.siteadmin != 0xFFFFFFFF)) { permissions += "Locked, "; }
if ((user.siteadmin != null) && ((user.siteadmin & 32) != 0) && (user.siteadmin != 0xFFFFFFFF)) { msg += "Locked, "; } permissions += "<span title='Server Permissions'>";
msg += "<span title='Server Permissions'>";
if ((user.siteadmin == null) || (user.siteadmin == 0) || (user.siteadmin == 32)) { if ((user.siteadmin == null) || (user.siteadmin == 0) || (user.siteadmin == 32)) {
msg += "User"; permissions += "User";
} else if (user.siteadmin == 8) { } else if (user.siteadmin == 8) {
msg += "User with server files"; permissions += "User + Files";
} else if (user.siteadmin == 0xFFFFFFFF) { } else if (user.siteadmin == 0xFFFFFFFF) {
msg += "Administrator"; permissions += "Administrator";
} else { } else {
msg += "Partial"; permissions += "Partial";
} }
msg += "</span>"; permissions += "</span>";
if ((user.quota != null) && ((user.siteadmin & 8) != 0)) { msg += ", " + (user.quota / 1024) + " k"; } //if ((user.quota != null) && ((user.siteadmin & 8) != 0)) { msg += ", " + (user.quota / 1024) + " k"; }
if (self) { msg += "</a>"; } if (self) { permissions += "</a>"; }
var groups = 0
if (user.links) { for (var i in user.links) { groups++; } }
var username = EscapeHtml(user.name), emailVerified = ''; var username = EscapeHtml(user.name), emailVerified = '';
if (serverinfo.emailcheck == true) { emailVerified = ((user.emailVerified != true) ? ' <b style=color:red title="Email is not verified">&#x1F5F4</b>' : ' <b style=color:green title="Email is verified">&#x1F5F8</b>'); } if (serverinfo.emailcheck == true) { emailVerified = ((user.emailVerified != true) ? ' <b style=color:red title="Email is not verified">&#x1F5F4</b>' : ' <b style=color:green title="Email is verified">&#x1F5F8</b>'); }
if (user.email != null) { username += ', <a onclick=doemail(event,\"' + user.email + '\")>' + user.email + '</a>' + emailVerified; } if (user.email != null) { username += ', <a onclick=doemail(event,\"' + user.email + '\")>' + user.email + '</a>' + emailVerified; }
@ -6436,7 +6442,7 @@
x += '<div class=bar style=height:24px;width:100%;font-size:medium>'; x += '<div class=bar style=height:24px;width:100%;font-size:medium>';
x += '<div style=float:left;height:24px;width:24px;background-color:white><div class="' + icon + gray + '" style=width:16px;margin-top:4px;margin-left:2px;height:16px></div></div>'; x += '<div style=float:left;height:24px;width:24px;background-color:white><div class="' + icon + gray + '" style=width:16px;margin-top:4px;margin-left:2px;height:16px></div></div>';
x += '<div class=g1 style=height:24px;float:left></div><div class=g2 style=height:24px;float:right></div>'; x += '<div class=g1 style=height:24px;float:left></div><div class=g2 style=height:24px;float:right></div>';
x += '<div><span>' + username + '</span>' + msg2 + '<span style=float:right>' + msg + '</span></div></div>'; // </td></tr> x += '<div><span>' + username + '</span>' + msg + '</div></div><td style=text-align:center>' + groups + '<td style=text-align:center>' + lastAccess + '<td style=text-align:center>' + permissions;
return x; return x;
} }