From 3394e5e2f68859986f50cab8aeda30a752d976ed Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Wed, 13 Nov 2019 14:58:57 -0800 Subject: [PATCH] Fixed user group permissions in web app. --- package.json | 2 +- views/default-min.handlebars | 8 ++-- views/default-mobile-min.handlebars | 2 +- views/default-mobile.handlebars | 40 ++++++++++++------- views/default.handlebars | 8 ++-- views/translations/default-min_fr.handlebars | 8 ++-- .../default-mobile-min_fr.handlebars | 2 +- .../translations/default-mobile_fr.handlebars | 40 ++++++++++++------- views/translations/default_fr.handlebars | 8 ++-- 9 files changed, 71 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index 1018d726..7c186185 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.3-s", + "version": "0.4.3-t", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 6ede98fe..4df2d61b 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -6498,10 +6498,10 @@ if (meshrights & 8) { Q('p20remotecontrol').checked = true; if (meshrights & 256) { Q('p20remoteview').checked = true; } - if (meshrights & 512) { Q('p20remotelimitedinput').checked = true; } - if (meshrights & 1024) { Q('p20noterminal').checked = true; } - if (meshrights & 2048) { Q('p20nofiles').checked = true; } - if (meshrights & 4096) { Q('p20noamt').checked = true; } + if (meshrights & 512) { Q('p20noterminal').checked = true; } + if (meshrights & 1024) { Q('p20nofiles').checked = true; } + if (meshrights & 2048) { Q('p20noamt').checked = true; } + if (meshrights & 4096) { Q('p20remotelimitedinput').checked = true; } } if (meshrights & 16) { Q('p20meshagentconsole').checked = true; } if (meshrights & 32) { Q('p20meshserverfiles').checked = true; } diff --git a/views/default-mobile-min.handlebars b/views/default-mobile-min.handlebars index a8a4a827..8163684b 100644 --- a/views/default-mobile-min.handlebars +++ b/views/default-mobile-min.handlebars @@ -1 +1 @@ -{{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file +{{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 7f5e7183..40484047 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -3221,6 +3221,7 @@ x += '
'; x += '
'; x += '
'; + x += '
'; x += ''; setDialogMode(2, "Add User to Mesh", 3, p20showAddMeshUserDialogEx, x); p20validateAddMeshUserDialog(); @@ -3229,20 +3230,24 @@ function p20validateAddMeshUserDialog() { var meshrights = currentMesh.links[userinfo._id].rights; - QE('idx_dlgOkButton', (Q('dp20username').value.length > 0)); + var nc = !Q('p20fulladmin').checked; QE('p20fulladmin', meshrights == 0xFFFFFFFF); - QE('p20editmesh', (!Q('p20fulladmin').checked) && (meshrights == 0xFFFFFFFF)); - QE('p20manageusers', !Q('p20fulladmin').checked); - QE('p20managecomputers', !Q('p20fulladmin').checked); - QE('p20remotecontrol', !Q('p20fulladmin').checked); - QE('p20meshagentconsole', !Q('p20fulladmin').checked); - QE('p20meshserverfiles', !Q('p20fulladmin').checked); - QE('p20wakedevices', !Q('p20fulladmin').checked); - QE('p20editnotes', !Q('p20fulladmin').checked); - QE('p20remoteview', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked); - QE('p20noterminal', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked); - QE('p20nofiles', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked); - QE('p20noamt', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked); + QE('p20editmesh', nc && (meshrights == 0xFFFFFFFF)); + QE('p20manageusers', nc); + QE('p20managecomputers', nc); + QE('p20remotecontrol', nc); + QE('p20meshagentconsole', nc); + QE('p20meshserverfiles', nc); + QE('p20wakedevices', nc); + QE('p20editnotes', nc); + QE('p20limitevents', nc); + QE('p20remoteview', nc && Q('p20remotecontrol').checked); + QE('p20remotelimitedinput', nc && Q('p20remotecontrol').checked && !Q('p20remoteview').checked); + QE('p20noterminal', nc && Q('p20remotecontrol').checked); + QE('p20nofiles', nc && Q('p20remotecontrol').checked); + QE('p20noamt', nc && Q('p20remotecontrol').checked); + QE('p20chatnotify', nc); + QE('p20uninstall', nc); } function p20showAddMeshUserDialogEx() { @@ -3260,8 +3265,14 @@ if (Q('p20noterminal').checked == true) meshadmin += 512; if (Q('p20nofiles').checked == true) meshadmin += 1024; if (Q('p20noamt').checked == true) meshadmin += 2048; + if (Q('p20remotelimitedinput').checked == true) meshadmin += 4096; + if (Q('p20limitevents').checked == true) meshadmin += 8192; + if (Q('p20chatnotify').checked == true) meshadmin += 16384; + if (Q('p20uninstall').checked == true) meshadmin += 32768; } - meshserver.send({ action: 'addmeshuser', meshid: currentMesh._id, meshname: currentMesh.name, username: Q('dp20username').value, meshadmin: meshadmin }); + var users = Q('dp20username').value.split(','), users2 = []; + for (var i in users) { users2.push(users[i].trim()); } + meshserver.send({ action: 'addmeshuser', meshid: currentMesh._id, meshname: currentMesh.name, usernames: users2, meshadmin: meshadmin }); } function p20viewuser(userid) { @@ -3284,6 +3295,7 @@ if (((meshrights & 8) != 0) && ((meshrights & 4096) != 0) && ((meshrights & 256) == 0)) r.push("Limited Input"); if ((meshrights & 8192) != 0) r.push("Self Events Only"); if ((meshrights & 16384) != 0) r.push("Chat & Notify"); + if ((meshrights & 32768) != 0) r.push("Uninstall"); } if (r.length == 0) { r.push("No Rights"); } var buttons = 1, x = addHtmlValue("User", EscapeHtml(decodeURIComponent(userid.split('/')[2]))); diff --git a/views/default.handlebars b/views/default.handlebars index c3f0b5ea..0303b02b 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -7480,10 +7480,10 @@ if (meshrights & 8) { Q('p20remotecontrol').checked = true; if (meshrights & 256) { Q('p20remoteview').checked = true; } - if (meshrights & 512) { Q('p20remotelimitedinput').checked = true; } - if (meshrights & 1024) { Q('p20noterminal').checked = true; } - if (meshrights & 2048) { Q('p20nofiles').checked = true; } - if (meshrights & 4096) { Q('p20noamt').checked = true; } + if (meshrights & 512) { Q('p20noterminal').checked = true; } + if (meshrights & 1024) { Q('p20nofiles').checked = true; } + if (meshrights & 2048) { Q('p20noamt').checked = true; } + if (meshrights & 4096) { Q('p20remotelimitedinput').checked = true; } } if (meshrights & 16) { Q('p20meshagentconsole').checked = true; } if (meshrights & 32) { Q('p20meshserverfiles').checked = true; } diff --git a/views/translations/default-min_fr.handlebars b/views/translations/default-min_fr.handlebars index 7433f9b6..4ac5b33f 100644 --- a/views/translations/default-min_fr.handlebars +++ b/views/translations/default-min_fr.handlebars @@ -6498,10 +6498,10 @@ if (meshrights & 8) { Q('p20remotecontrol').checked = true; if (meshrights & 256) { Q('p20remoteview').checked = true; } - if (meshrights & 512) { Q('p20remotelimitedinput').checked = true; } - if (meshrights & 1024) { Q('p20noterminal').checked = true; } - if (meshrights & 2048) { Q('p20nofiles').checked = true; } - if (meshrights & 4096) { Q('p20noamt').checked = true; } + if (meshrights & 512) { Q('p20noterminal').checked = true; } + if (meshrights & 1024) { Q('p20nofiles').checked = true; } + if (meshrights & 2048) { Q('p20noamt').checked = true; } + if (meshrights & 4096) { Q('p20remotelimitedinput').checked = true; } } if (meshrights & 16) { Q('p20meshagentconsole').checked = true; } if (meshrights & 32) { Q('p20meshserverfiles').checked = true; } diff --git a/views/translations/default-mobile-min_fr.handlebars b/views/translations/default-mobile-min_fr.handlebars index 89504e49..67bd1833 100644 --- a/views/translations/default-mobile-min_fr.handlebars +++ b/views/translations/default-mobile-min_fr.handlebars @@ -1 +1 @@ -{{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file +{{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/translations/default-mobile_fr.handlebars b/views/translations/default-mobile_fr.handlebars index d0cbb50f..13ee6504 100644 --- a/views/translations/default-mobile_fr.handlebars +++ b/views/translations/default-mobile_fr.handlebars @@ -3219,6 +3219,7 @@ x += '
'; x += '
'; x += '
'; + x += '
'; x += ''; setDialogMode(2, "Ajouter un utilisateur au groupe", 3, p20showAddMeshUserDialogEx, x); p20validateAddMeshUserDialog(); @@ -3227,20 +3228,24 @@ function p20validateAddMeshUserDialog() { var meshrights = currentMesh.links[userinfo._id].rights; - QE('idx_dlgOkButton', (Q('dp20username').value.length > 0)); + var nc = !Q('p20fulladmin').checked; QE('p20fulladmin', meshrights == 0xFFFFFFFF); - QE('p20editmesh', (!Q('p20fulladmin').checked) && (meshrights == 0xFFFFFFFF)); - QE('p20manageusers', !Q('p20fulladmin').checked); - QE('p20managecomputers', !Q('p20fulladmin').checked); - QE('p20remotecontrol', !Q('p20fulladmin').checked); - QE('p20meshagentconsole', !Q('p20fulladmin').checked); - QE('p20meshserverfiles', !Q('p20fulladmin').checked); - QE('p20wakedevices', !Q('p20fulladmin').checked); - QE('p20editnotes', !Q('p20fulladmin').checked); - QE('p20remoteview', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked); - QE('p20noterminal', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked); - QE('p20nofiles', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked); - QE('p20noamt', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked); + QE('p20editmesh', nc && (meshrights == 0xFFFFFFFF)); + QE('p20manageusers', nc); + QE('p20managecomputers', nc); + QE('p20remotecontrol', nc); + QE('p20meshagentconsole', nc); + QE('p20meshserverfiles', nc); + QE('p20wakedevices', nc); + QE('p20editnotes', nc); + QE('p20limitevents', nc); + QE('p20remoteview', nc && Q('p20remotecontrol').checked); + QE('p20remotelimitedinput', nc && Q('p20remotecontrol').checked && !Q('p20remoteview').checked); + QE('p20noterminal', nc && Q('p20remotecontrol').checked); + QE('p20nofiles', nc && Q('p20remotecontrol').checked); + QE('p20noamt', nc && Q('p20remotecontrol').checked); + QE('p20chatnotify', nc); + QE('p20uninstall', nc); } function p20showAddMeshUserDialogEx() { @@ -3258,8 +3263,14 @@ if (Q('p20noterminal').checked == true) meshadmin += 512; if (Q('p20nofiles').checked == true) meshadmin += 1024; if (Q('p20noamt').checked == true) meshadmin += 2048; + if (Q('p20remotelimitedinput').checked == true) meshadmin += 4096; + if (Q('p20limitevents').checked == true) meshadmin += 8192; + if (Q('p20chatnotify').checked == true) meshadmin += 16384; + if (Q('p20uninstall').checked == true) meshadmin += 32768; } - meshserver.send({ action: 'addmeshuser', meshid: currentMesh._id, meshname: currentMesh.name, username: Q('dp20username').value, meshadmin: meshadmin }); + var users = Q('dp20username').value.split(','), users2 = []; + for (var i in users) { users2.push(users[i].trim()); } + meshserver.send({ action: 'addmeshuser', meshid: currentMesh._id, meshname: currentMesh.name, usernames: users2, meshadmin: meshadmin }); } function p20viewuser(userid) { @@ -3282,6 +3293,7 @@ if (((meshrights & 8) != 0) && ((meshrights & 4096) != 0) && ((meshrights & 256) == 0)) r.push("Limited Input"); if ((meshrights & 8192) != 0) r.push("Self Events Only"); if ((meshrights & 16384) != 0) r.push("Chat & Notify"); + if ((meshrights & 32768) != 0) r.push("Uninstall"); } if (r.length == 0) { r.push("No Rights"); } var buttons = 1, x = addHtmlValue("User", EscapeHtml(decodeURIComponent(userid.split('/')[2]))); diff --git a/views/translations/default_fr.handlebars b/views/translations/default_fr.handlebars index 42719933..8235c4c0 100644 --- a/views/translations/default_fr.handlebars +++ b/views/translations/default_fr.handlebars @@ -7478,10 +7478,10 @@ if (meshrights & 8) { Q('p20remotecontrol').checked = true; if (meshrights & 256) { Q('p20remoteview').checked = true; } - if (meshrights & 512) { Q('p20remotelimitedinput').checked = true; } - if (meshrights & 1024) { Q('p20noterminal').checked = true; } - if (meshrights & 2048) { Q('p20nofiles').checked = true; } - if (meshrights & 4096) { Q('p20noamt').checked = true; } + if (meshrights & 512) { Q('p20noterminal').checked = true; } + if (meshrights & 1024) { Q('p20nofiles').checked = true; } + if (meshrights & 2048) { Q('p20noamt').checked = true; } + if (meshrights & 4096) { Q('p20remotelimitedinput').checked = true; } } if (meshrights & 16) { Q('p20meshagentconsole').checked = true; } if (meshrights & 32) { Q('p20meshserverfiles').checked = true; }