Added verified email argument to MeshCtrl.

Ylian Saint-Hilaire committed Jul 1, 2019 at 16:46 UTC dd8dc451893840d78c2db00d6ea8d590622d89a2
4 files changed +32 -31
meshctrl.js
+27 -26
@@ -91,7 +91,7 @@ if (args['_'].length == 0) {
91 console.log(" MeshCtrl ServerInfo --loginuser myaccountname --loginpass mypassword");
92 console.log(" MeshCtrl ServerInfo --loginuser myaccountname --loginkeyfile key.txt");
93 console.log("\r\nOptional arguments:\r\n");
94 - console.log(" --json - Show result as JSON.");
94 + console.log(" --json - Show result as JSON.");
95 break;
96 }
97 case 'userinfo': {
@@ -99,7 +99,7 @@ if (args['_'].length == 0) {
99 console.log(" MeshCtrl UserInfo --loginuser myaccountname --loginpass mypassword");
100 console.log(" MeshCtrl UserInfo --loginuser myaccountname --loginkeyfile key.txt");
101 console.log("\r\nOptional arguments:\r\n");
102 - console.log(" --json - Show result as JSON.");
102 + console.log(" --json - Show result as JSON.");
103 break;
104 }
105 case 'listusers': {
@@ -108,9 +108,9 @@ if (args['_'].length == 0) {
108 console.log(" MeshCtrl ListUsers --json");
109 console.log(" MeshCtrl ListUsers --nameexists \"bob\"");
110 console.log("\r\nOptional arguments:\r\n");
111 - console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
112 - console.log(" --nameexists [name] - Return id if name exists.");
113 - console.log(" --json - Show result as JSON.");
111 + console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
112 + console.log(" --nameexists [name] - Return id if name exists.");
113 + console.log(" --json - Show result as JSON.");
114 break;
115 }
116 case 'listdevicegroups': {
@@ -118,36 +118,37 @@ if (args['_'].length == 0) {
118 console.log(" MeshCtrl ListDeviceGroups ");
119 console.log(" MeshCtrl ListDeviceGroups --json");
120 console.log("\r\nOptional arguments:\r\n");
121 - console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
122 - console.log(" --nameexists [name] - Return id if name exists.");
123 - console.log(" --emailexists [email] - Return id if email exists.");
124 - console.log(" --json - Show result as JSON.");
121 + console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
122 + console.log(" --nameexists [name] - Return id if name exists.");
123 + console.log(" --emailexists [email] - Return id if email exists.");
124 + console.log(" --json - Show result as JSON.");
125 break;
126 }
127 case 'adduser': {
128 console.log("Add a new user account, Example usages:\r\n");
129 console.log(" MeshCtrl AddUser --user newaccountname --pass newpassword");
130 console.log("\r\nRequired arguments:\r\n");
131 - console.log(" --user [name] - New account name.");
132 - console.log(" --pass [password] - New account password.");
133 - console.log(" --randompass - Create account with a random password.");
131 + console.log(" --user [name] - New account name.");
132 + console.log(" --pass [password] - New account password.");
133 + console.log(" --randompass - Create account with a random password.");
134 console.log("\r\nOptional arguments:\r\n");
135 - console.log(" --email [email] - New account email address.");
136 - console.log(" --resetpass - Request password reset on next login.");
137 - console.log(" --siteadmin - Create the account as full site administrator.");
138 - console.log(" --manageusers - Allow this account to manage server users.");
139 - console.log(" --fileaccess - Allow this account to store server files.");
140 - console.log(" --serverupdate - Allow this account to update the server.");
141 - console.log(" --locked - This account will be locked.");
142 - console.log(" --nonewgroups - Account will not be allowed to create device groups.");
143 - console.log(" --notools - Account not see MeshCMD download links.");
135 + console.log(" --email [email] - New account email address.");
136 + console.log(" --emailverified - New account email is verified.");
137 + console.log(" --resetpass - Request password reset on next login.");
138 + console.log(" --siteadmin - Create the account as full site administrator.");
139 + console.log(" --manageusers - Allow this account to manage server users.");
140 + console.log(" --fileaccess - Allow this account to store server files.");
141 + console.log(" --serverupdate - Allow this account to update the server.");
142 + console.log(" --locked - This account will be locked.");
143 + console.log(" --nonewgroups - Account will not be allowed to create device groups.");
144 + console.log(" --notools - Account not see MeshCMD download links.");
145 break;
146 }
147 case 'removeuser': {
148 console.log("Delete a user account, Example usages:\r\n");
149 console.log(" MeshCtrl RemoveUser --userid accountid");
150 console.log("\r\nRequired arguments:\r\n");
150 - console.log(" --userid [id] - Account identifier.");
151 + console.log(" --userid [id] - Account identifier.");
152 break;
153 }
154 case 'adddevicegroup': {
@@ -155,10 +156,10 @@ if (args['_'].length == 0) {
156 console.log(" MeshCtrl AddDeviceGroup --name newgroupname");
157 console.log(" MeshCtrl AddDeviceGroup --name newgroupname --desc description --amtonly");
158 console.log("\r\nRequired arguments:\r\n");
158 - console.log(" --name [name] - Name of the new group.");
159 + console.log(" --name [name] - Name of the new group.");
160 console.log("\r\nOptional arguments:\r\n");
160 - console.log(" --desc [description] - New group description.");
161 - console.log(" --amtonly - New group is agent-less, Intel AMT only.");
161 + console.log(" --desc [description] - New group description.");
162 + console.log(" --amtonly - New group is agent-less, Intel AMT only.");
163 break;
164 }
165 case 'removedevicegroup': {
@@ -290,7 +291,7 @@ function serverConnect() {
291 if (args.notools) { siteadmin |= 128; }
292 if (args.randompass) { args.pass = getRandomAmtPassword(); }
293 var op = { action: 'adduser', username: args.user, pass: args.pass, responseid: 'meshctrl' };
293 - if (args.email) { op.email = args.email; }
294 + if (args.email) { op.email = args.email; if (args.emailverified) { op.emailVerified = true; } }
295 if (args.resetpass) { op.resetNextLogin = true; }
296 if (siteadmin != 0) { op.siteadmin = siteadmin; }
297 ws.send(JSON.stringify(op));
meshuser.js
+4 -3
@@ -1066,7 +1066,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1066 var newuserid = 'user/' + domain.id + '/' + command.users[i].user.toLowerCase();
1067 var newuser = { type: 'user', _id: newuserid, name: command.users[i].user, creation: Math.floor(Date.now() / 1000), domain: domain.id };
1068 if (domain.newaccountsrights) { newuser.siteadmin = domain.newaccountsrights; }
1069 - if (command.users[i].email != null) { newuser.email = command.users[i].email; } // Email
1069 + if (command.users[i].email != null) { newuser.email = command.users[i].email; if (command.users[i].emailVerified === true) { newuser.emailVerified = true; } } // Email
1070 if (command.users[i].resetNextLogin === true) { newuser.passchange = -1; } else { newuser.passchange = Math.floor(Date.now() / 1000); }
1071 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.
1072
@@ -1103,6 +1103,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1103 var err = null, newusername, newuserid;
1104 try {
1105 if ((user.siteadmin & 2) == 0) { err = 'Permission denied'; }
1106 + else if ((domain.auth == 'sspi') || (domain.auth == 'ldap')) { err = 'Unable to add user in this mode'; }
1107 else if (common.validateUsername(command.username, 1, 64) == false) { err = 'Invalid username'; } // Username is between 1 and 64 characters, no spaces
1108 else if (common.validateString(command.pass, 1, 256) == false) { err = 'Invalid password'; } // Password is between 1 and 256 characters
1109 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
1148 var newuser = { type: 'user', _id: newuserid, name: newusername, creation: Math.floor(Date.now() / 1000), domain: domain.id };
1149 if (command.siteadmin != null) { newuser.siteadmin = command.siteadmin; }
1150 else if (domain.newaccountsrights) { newuser.siteadmin = domain.newaccountsrights; }
1150 - if (command.email != null) { newuser.email = command.email; } // Email
1151 + if (command.email != null) { newuser.email = command.email; if (command.emailVerified === true) { newuser.emailVerified = true; } } // Email
1152 if (command.resetNextLogin === true) { newuser.passchange = -1; } else { newuser.passchange = Math.floor(Date.now() / 1000); }
1152 - if ((user.groups != null) && (user.groups.length > 0)) { newuser.groups = user.groups; } // New account are automatically part of our groups.
1153 +
1154 parent.users[newuserid] = newuser;
1155
1156 // Create a user, generate a salt and hash the password
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.3.7-a",
3 + "version": "0.3.7-c",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
views/default-min.handlebars
-1
@@ -7915,7 +7915,6 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
7915 node.namel = node.name.toLowerCase();
7916 if (node.rname) { node.rnamel = node.rname.toLowerCase(); } else { node.rnamel = node.namel; }
7917 if (message.event.node.icon) { node.icon = message.event.node.icon; }
7918 - console.log(node);
7918
7919 // Web page update
7920 masterUpdate(2 | 4 | 8 | 16);