From 9f5a0340fd55641d92a768927cd17a276b5f9d05 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 1 Mar 2019 11:47:58 -0800 Subject: [PATCH] Improved user management page. --- agents/meshcore.js | 24 ++++++++++------ package.json | 2 +- views/default-min.handlebars | 2 +- views/default-mobile-min.handlebars | 2 +- views/default-mobile.handlebars | 2 +- views/default.handlebars | 44 ++++++++++++++++------------- 6 files changed, 44 insertions(+), 32 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index 4a0c5097..838ef600 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -31,6 +31,9 @@ var MESHRIGHT_SERVERFILES = 32; var MESHRIGHT_WAKEDEVICE = 64; var MESHRIGHT_SETNOTES = 128; var MESHRIGHT_REMOTEVIEW = 256; +var MESHRIGHT_NOTERMINAL = 512; +var MESHRIGHT_NOFILES = 1024; +var MESHRIGHT_NOAMT = 2048; function createMeshCore(agent) { 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);*/ } } else { // 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 this.httprequest.protocol = parseInt(data); if (typeof this.httprequest.protocol != 'number') { this.httprequest.protocol = 0; } if (this.httprequest.protocol == 1) { - // Check user access rights - if ((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) { + // Check user access rights for terminal + 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!! this.httprequest.protocol = 999999; - sendConsoleText('Error: No Remote Control Rights.'); + this.httprequest.s.end(); + sendConsoleText('Error: No Terminal Control Rights.'); 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"); } } 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)) { // Disengage this tunnel, user does not have the rights to do this!! this.httprequest.protocol = 999999; - sendConsoleText('Error: No Remote Control Rights.'); + this.httprequest.s.end(); + sendConsoleText('Error: No Desktop Control Rights.'); return; } @@ -791,11 +796,12 @@ function createMeshCore(agent) { this.on('data', onTunnelControlData); //this.write('MeshCore KVM Hello!1'); } else if (this.httprequest.protocol == 5) { - // Check user access rights - if ((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) { + // Check user access rights for files + 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!! this.httprequest.protocol = 999999; - sendConsoleText('Error: No Remote Control Rights.'); + this.httprequest.s.end(); + sendConsoleText('Error: No Files Control Rights.'); return; } diff --git a/package.json b/package.json index ae359d69..49d4a2d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.2.9-j", + "version": "0.2.9-l", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 2106c02d..04f26508 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ - MeshCentral
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file + MeshCentral
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file diff --git a/views/default-mobile-min.handlebars b/views/default-mobile-min.handlebars index ef1fc4f6..a5b032a3 100644 --- a/views/default-mobile-min.handlebars +++ b/views/default-mobile-min.handlebars @@ -1 +1 @@ - MeshCentral
{{{title}}}
{{{title2}}}
\ No newline at end of file + MeshCentral
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 62456666..4b829a90 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -1873,7 +1873,7 @@ var menus = []; 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 != 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); } diff --git a/views/default.handlebars b/views/default.handlebars index 49b438d5..266f3441 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -6358,13 +6358,16 @@ // Display the users using the sorted list var x = '', addHeader = true; + + x += ' + x += '
' + username + '' + msg + '
NameGroupsLast AccessPermissions'; + // Online users for (var i in sortedUserIds) { var user = users[sortedUserIds[i]], sessions = null; if (wssessions != null) { sessions = wssessions[user._id]; } if ((sessions != null) && (user.name.toLowerCase().indexOf(userSearch) >= 0)) { if (maxUsers > 0) { - if (addHeader) { x += '
Online Users'; addHeader = false; } + if (addHeader) { x += '
Online Users'; addHeader = false; } x += addUserHtml(user, sessions); maxUsers--; } else { @@ -6379,7 +6382,7 @@ if (wssessions != null) { sessions = wssessions[user._id]; } if ((sessions == null) && (user.name.toLowerCase().indexOf(userSearch) >= 0)) { if (maxUsers > 0) { - if (addHeader) { x += '
Offline Users'; addHeader = false; } + if (addHeader) { x += '
Offline Users'; addHeader = false; } x += addUserHtml(user, sessions); maxUsers--; } else { @@ -6398,33 +6401,36 @@ } 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) { gray = ''; if (self) { - msg2 = ""; - msg2 += ""; + msg = ""; + msg += ""; } - if (sessions == 1) { msg += '1 active session'; } else { msg += sessions + ' active sessions'; } + if (sessions == 1) { lastAccess += '1 session'; } else { lastAccess += sessions + ' sessions'; } } else { - if (user.login) { msg += '' + new Date(user.login * 1000).toLocaleDateString() + ''; } + if (user.login) { lastAccess += '' + new Date(user.login * 1000).toLocaleDateString() + ''; } } - if (msg != '') msg += ', '; - if (self) { msg += ""; } - if ((user.siteadmin != null) && ((user.siteadmin & 32) != 0) && (user.siteadmin != 0xFFFFFFFF)) { msg += "Locked, "; } - msg += ""; + if (self) { permissions += ""; } + if ((user.siteadmin != null) && ((user.siteadmin & 32) != 0) && (user.siteadmin != 0xFFFFFFFF)) { permissions += "Locked, "; } + permissions += ""; if ((user.siteadmin == null) || (user.siteadmin == 0) || (user.siteadmin == 32)) { - msg += "User"; + permissions += "User"; } else if (user.siteadmin == 8) { - msg += "User with server files"; + permissions += "User + Files"; } else if (user.siteadmin == 0xFFFFFFFF) { - msg += "Administrator"; + permissions += "Administrator"; } else { - msg += "Partial"; + permissions += "Partial"; } - msg += ""; - if ((user.quota != null) && ((user.siteadmin & 8) != 0)) { msg += ", " + (user.quota / 1024) + " k"; } - if (self) { msg += ""; } + permissions += ""; + //if ((user.quota != null) && ((user.siteadmin & 8) != 0)) { msg += ", " + (user.quota / 1024) + " k"; } + if (self) { permissions += ""; } + + var groups = 0 + if (user.links) { for (var i in user.links) { groups++; } } + var username = EscapeHtml(user.name), emailVerified = ''; if (serverinfo.emailcheck == true) { emailVerified = ((user.emailVerified != true) ? ' 🗴' : ' 🗸'); } if (user.email != null) { username += ', ' + user.email + '' + emailVerified; } @@ -6436,7 +6442,7 @@ x += '
'; x += '
'; x += '
'; - x += '
' + username + '' + msg2 + '' + msg + '
'; //
' + groups + '' + lastAccess + '' + permissions; return x; }