More agent invite code feature fixes.

This commit is contained in:
Ylian Saint-Hilaire 2020-03-17 09:40:16 -07:00
parent cc5e489108
commit 3a61a77b8a
5 changed files with 526 additions and 475 deletions

View File

@ -2273,6 +2273,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if ((common.validateInt(command.flags) == true) && (command.flags != mesh.flags)) { if (change != '') change += ' and flags changed'; else change += 'Group "' + mesh.name + '" flags changed'; mesh.flags = command.flags; } if ((common.validateInt(command.flags) == true) && (command.flags != mesh.flags)) { if (change != '') change += ' and flags changed'; else change += 'Group "' + mesh.name + '" flags changed'; mesh.flags = command.flags; }
if ((common.validateInt(command.consent) == true) && (command.consent != mesh.consent)) { if (change != '') change += ' and consent changed'; else change += 'Group "' + mesh.name + '" consent changed'; mesh.consent = command.consent; } if ((common.validateInt(command.consent) == true) && (command.consent != mesh.consent)) { if (change != '') change += ' and consent changed'; else change += 'Group "' + mesh.name + '" consent changed'; mesh.consent = command.consent; }
// See if we need to change device group invitation codes
if (mesh.mtype == 2) {
if (command.invite === '*') { if (command.invite === '*') {
// Clear invite codes // Clear invite codes
if (mesh.invite != null) { delete mesh.invite; } if (mesh.invite != null) { delete mesh.invite; }
@ -2280,10 +2282,23 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
} else if (typeof command.invite === 'object') { } else if (typeof command.invite === 'object') {
// Set invite codes // Set invite codes
if ((mesh.invite == null) || (mesh.invite.codes != command.invite.codes) || (mesh.invite.flags != command.invite.flags)) { if ((mesh.invite == null) || (mesh.invite.codes != command.invite.codes) || (mesh.invite.flags != command.invite.flags)) {
// Check if an invite code is not already in use.
var dup = null;
for (var i in command.invite.codes) {
for (var j in parent.meshes) {
if ((j != command.meshid) && (parent.meshes[j].invite != null) && (parent.meshes[j].invite.codes.indexOf(command.invite.codes[i]) >= 0)) { dup = command.invite.codes[i]; break; }
}
}
if (dup != null) {
// A duplicate was found, don't allow this change.
displayNotificationMessage('Error, invite code \"' + dup + '\" already in use.', 'Invite Codes');
return;
}
mesh.invite = { codes: command.invite.codes, flags: command.invite.flags }; mesh.invite = { codes: command.invite.codes, flags: command.invite.flags };
if (change != '') { change += ' and invite code changed'; } else { change += 'Group "' + mesh.name + '" invite code changed'; } if (change != '') { change += ' and invite code changed'; } else { change += 'Group "' + mesh.name + '" invite code changed'; }
} }
} }
}
if (change != '') { if (change != '') {
db.Set(common.escapeLinksFieldName(mesh)); db.Set(common.escapeLinksFieldName(mesh));

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.5.0-h", "version": "0.5.0-i",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -47,8 +47,8 @@
"name": "Local server name", "name": "Local server name",
"info": "Information about this server" "info": "Information about this server"
}, },
"_TlsOffload": true, "_TlsOffload": "127.0.0.1",
"_trustedproxy": true, "_TrustedProxy": "127.0.0.1",
"_MpsPort": 44330, "_MpsPort": 44330,
"_MpsAliasPort": 4433, "_MpsAliasPort": 4433,
"_MpsAliasHost": "mps.mydomain.com", "_MpsAliasHost": "mps.mydomain.com",

File diff suppressed because it is too large Load Diff

View File

@ -8147,10 +8147,9 @@
x += addHtmlValue("Notifications", addLink(meshNotifyStr.join(', '), 'p20editMeshNotify()')); x += addHtmlValue("Notifications", addLink(meshNotifyStr.join(', '), 'p20editMeshNotify()'));
// Display invitation codes // Display invitation codes
if (features & 0x01000000) { if ((features & 0x01000000) && (currentMesh.mtype == 2)) {
var inviteCodeStr = '<i>' + "None" + '</i>', icodes = false; var inviteCodeStr = '<i>' + "None" + '</i>', icodes = false;
if (currentMesh.invite != null) { icodes = true; inviteCodeStr = currentMesh.invite.codes.join(', '); /* + ', ' + currentMesh.invite.flags;*/ } if (currentMesh.invite != null) { icodes = true; inviteCodeStr = currentMesh.invite.codes.join(', '); /* + ', ' + currentMesh.invite.flags;*/ }
//x += addHtmlValue("Invite Codes", addLink(inviteCodeStr, 'p20editmeshInviteCode()'));
x += addHtmlValue("Invite Codes", addLinkConditional(inviteCodeStr, 'p20editmeshInviteCode()', (meshrights & 1) || (icodes))); x += addHtmlValue("Invite Codes", addLinkConditional(inviteCodeStr, 'p20editmeshInviteCode()', (meshrights & 1) || (icodes)));
} }