Fixed user group permissions in web app.

This commit is contained in:
Ylian Saint-Hilaire 2019-11-13 14:58:57 -08:00
parent b679f23f74
commit 3394e5e2f6
9 changed files with 71 additions and 47 deletions

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.4.3-s",
"version": "0.4.3-t",
"keywords": [
"Remote Management",
"Intel AMT",

View File

@ -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; }

File diff suppressed because one or more lines are too long

View File

@ -3221,6 +3221,7 @@
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editnotes>' + "Edit Device Notes" + '</label><br>';
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20limitevents>' + "Show Only Own Events" + '</label><br>';
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20chatnotify>' + "Chat & Notify" + '</label><br>';
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20uninstall>' + "Uninstall Agent" + '</label><br>';
x += '</div>';
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])));

View File

@ -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; }

View File

@ -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; }

File diff suppressed because one or more lines are too long

View File

@ -3219,6 +3219,7 @@
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editnotes>' + "Edit Device Notes" + '</label><br>';
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20limitevents>' + "Show Only Own Events" + '</label><br>';
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20chatnotify>' + "Chat & Notify" + '</label><br>';
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20uninstall>' + "Uninstall Agent" + '</label><br>';
x += '</div>';
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])));

View File

@ -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; }