Added verified email argument to MeshCtrl.

This commit is contained in:
Ylian Saint-Hilaire 2019-07-01 16:46:05 -07:00
parent 8ca9a46eaf
commit b8b2c0f77b
4 changed files with 32 additions and 31 deletions

View File

@ -91,7 +91,7 @@ if (args['_'].length == 0) {
console.log(" MeshCtrl ServerInfo --loginuser myaccountname --loginpass mypassword");
console.log(" MeshCtrl ServerInfo --loginuser myaccountname --loginkeyfile key.txt");
console.log("\r\nOptional arguments:\r\n");
console.log(" --json - Show result as JSON.");
console.log(" --json - Show result as JSON.");
break;
}
case 'userinfo': {
@ -99,7 +99,7 @@ if (args['_'].length == 0) {
console.log(" MeshCtrl UserInfo --loginuser myaccountname --loginpass mypassword");
console.log(" MeshCtrl UserInfo --loginuser myaccountname --loginkeyfile key.txt");
console.log("\r\nOptional arguments:\r\n");
console.log(" --json - Show result as JSON.");
console.log(" --json - Show result as JSON.");
break;
}
case 'listusers': {
@ -108,9 +108,9 @@ if (args['_'].length == 0) {
console.log(" MeshCtrl ListUsers --json");
console.log(" MeshCtrl ListUsers --nameexists \"bob\"");
console.log("\r\nOptional arguments:\r\n");
console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
console.log(" --nameexists [name] - Return id if name exists.");
console.log(" --json - Show result as JSON.");
console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
console.log(" --nameexists [name] - Return id if name exists.");
console.log(" --json - Show result as JSON.");
break;
}
case 'listdevicegroups': {
@ -118,36 +118,37 @@ if (args['_'].length == 0) {
console.log(" MeshCtrl ListDeviceGroups ");
console.log(" MeshCtrl ListDeviceGroups --json");
console.log("\r\nOptional arguments:\r\n");
console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
console.log(" --nameexists [name] - Return id if name exists.");
console.log(" --emailexists [email] - Return id if email exists.");
console.log(" --json - Show result as JSON.");
console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
console.log(" --nameexists [name] - Return id if name exists.");
console.log(" --emailexists [email] - Return id if email exists.");
console.log(" --json - Show result as JSON.");
break;
}
case 'adduser': {
console.log("Add a new user account, Example usages:\r\n");
console.log(" MeshCtrl AddUser --user newaccountname --pass newpassword");
console.log("\r\nRequired arguments:\r\n");
console.log(" --user [name] - New account name.");
console.log(" --pass [password] - New account password.");
console.log(" --randompass - Create account with a random password.");
console.log(" --user [name] - New account name.");
console.log(" --pass [password] - New account password.");
console.log(" --randompass - Create account with a random password.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --email [email] - New account email address.");
console.log(" --resetpass - Request password reset on next login.");
console.log(" --siteadmin - Create the account as full site administrator.");
console.log(" --manageusers - Allow this account to manage server users.");
console.log(" --fileaccess - Allow this account to store server files.");
console.log(" --serverupdate - Allow this account to update the server.");
console.log(" --locked - This account will be locked.");
console.log(" --nonewgroups - Account will not be allowed to create device groups.");
console.log(" --notools - Account not see MeshCMD download links.");
console.log(" --email [email] - New account email address.");
console.log(" --emailverified - New account email is verified.");
console.log(" --resetpass - Request password reset on next login.");
console.log(" --siteadmin - Create the account as full site administrator.");
console.log(" --manageusers - Allow this account to manage server users.");
console.log(" --fileaccess - Allow this account to store server files.");
console.log(" --serverupdate - Allow this account to update the server.");
console.log(" --locked - This account will be locked.");
console.log(" --nonewgroups - Account will not be allowed to create device groups.");
console.log(" --notools - Account not see MeshCMD download links.");
break;
}
case 'removeuser': {
console.log("Delete a user account, Example usages:\r\n");
console.log(" MeshCtrl RemoveUser --userid accountid");
console.log("\r\nRequired arguments:\r\n");
console.log(" --userid [id] - Account identifier.");
console.log(" --userid [id] - Account identifier.");
break;
}
case 'adddevicegroup': {
@ -155,10 +156,10 @@ if (args['_'].length == 0) {
console.log(" MeshCtrl AddDeviceGroup --name newgroupname");
console.log(" MeshCtrl AddDeviceGroup --name newgroupname --desc description --amtonly");
console.log("\r\nRequired arguments:\r\n");
console.log(" --name [name] - Name of the new group.");
console.log(" --name [name] - Name of the new group.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --desc [description] - New group description.");
console.log(" --amtonly - New group is agent-less, Intel AMT only.");
console.log(" --desc [description] - New group description.");
console.log(" --amtonly - New group is agent-less, Intel AMT only.");
break;
}
case 'removedevicegroup': {
@ -290,7 +291,7 @@ function serverConnect() {
if (args.notools) { siteadmin |= 128; }
if (args.randompass) { args.pass = getRandomAmtPassword(); }
var op = { action: 'adduser', username: args.user, pass: args.pass, responseid: 'meshctrl' };
if (args.email) { op.email = args.email; }
if (args.email) { op.email = args.email; if (args.emailverified) { op.emailVerified = true; } }
if (args.resetpass) { op.resetNextLogin = true; }
if (siteadmin != 0) { op.siteadmin = siteadmin; }
ws.send(JSON.stringify(op));

View File

@ -1066,7 +1066,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var newuserid = 'user/' + domain.id + '/' + command.users[i].user.toLowerCase();
var newuser = { type: 'user', _id: newuserid, name: command.users[i].user, creation: Math.floor(Date.now() / 1000), domain: domain.id };
if (domain.newaccountsrights) { newuser.siteadmin = domain.newaccountsrights; }
if (command.users[i].email != null) { newuser.email = command.users[i].email; } // Email
if (command.users[i].email != null) { newuser.email = command.users[i].email; if (command.users[i].emailVerified === true) { newuser.emailVerified = true; } } // Email
if (command.users[i].resetNextLogin === true) { newuser.passchange = -1; } else { newuser.passchange = Math.floor(Date.now() / 1000); }
if ((command.users[i].groups != null) && (common.validateStrArray(command.users[i].groups, 1, 32))) { newuser.groups = command.users[i].groups; } // New account are automatically part of our groups.
@ -1103,6 +1103,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var err = null, newusername, newuserid;
try {
if ((user.siteadmin & 2) == 0) { err = 'Permission denied'; }
else if ((domain.auth == 'sspi') || (domain.auth == 'ldap')) { err = 'Unable to add user in this mode'; }
else if (common.validateUsername(command.username, 1, 64) == false) { err = 'Invalid username'; } // Username is between 1 and 64 characters, no spaces
else if (common.validateString(command.pass, 1, 256) == false) { err = 'Invalid password'; } // Password is between 1 and 256 characters
else if (command.username.indexOf('/') >= 0) { err = 'Invalid username'; } // Usernames can't have '/'
@ -1147,9 +1148,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var newuser = { type: 'user', _id: newuserid, name: newusername, creation: Math.floor(Date.now() / 1000), domain: domain.id };
if (command.siteadmin != null) { newuser.siteadmin = command.siteadmin; }
else if (domain.newaccountsrights) { newuser.siteadmin = domain.newaccountsrights; }
if (command.email != null) { newuser.email = command.email; } // Email
if (command.email != null) { newuser.email = command.email; if (command.emailVerified === true) { newuser.emailVerified = true; } } // Email
if (command.resetNextLogin === true) { newuser.passchange = -1; } else { newuser.passchange = Math.floor(Date.now() / 1000); }
if ((user.groups != null) && (user.groups.length > 0)) { newuser.groups = user.groups; } // New account are automatically part of our groups.
parent.users[newuserid] = newuser;
// Create a user, generate a salt and hash the password

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.3.7-a",
"version": "0.3.7-c",
"keywords": [
"Remote Management",
"Intel AMT",

View File

@ -7915,7 +7915,6 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
node.namel = node.name.toLowerCase();
if (node.rname) { node.rnamel = node.rname.toLowerCase(); } else { node.rnamel = node.namel; }
if (message.event.node.icon) { node.icon = message.event.node.icon; }
console.log(node);
// Web page update
masterUpdate(2 | 4 | 8 | 16);