Fixed batch user creation #2399

This commit is contained in:
Ylian Saint-Hilaire 2021-03-18 12:57:26 -07:00
parent 5f6c15f015
commit d356c7120e
1 changed files with 2 additions and 1 deletions

View File

@ -1893,9 +1893,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
} else { } else {
for (var i in command.users) { for (var i in command.users) {
// Check if this is an existing user // Check if this is an existing user
var newuserid = 'user/' + domain.id + '/' + command.users[i].user; 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 }; 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 (domain.newaccountsrights) { newuser.siteadmin = domain.newaccountsrights; }
if (common.validateString(command.users[i].realname, 1, 256)) { newuser.realname = command.users[i].realname; }
if (command.users[i].email != null) { newuser.email = command.users[i].email.toLowerCase(); if (command.users[i].emailVerified === true) { newuser.emailVerified = true; } } // Email, always lowercase if (command.users[i].email != null) { newuser.email = command.users[i].email.toLowerCase(); if (command.users[i].emailVerified === true) { newuser.emailVerified = true; } } // Email, always lowercase
if (command.users[i].resetNextLogin === true) { newuser.passchange = -1; } else { newuser.passchange = Math.floor(Date.now() / 1000); } if (command.users[i].resetNextLogin === true) { newuser.passchange = -1; } else { newuser.passchange = Math.floor(Date.now() / 1000); }
if (user.groups) { newuser.groups = user.groups; } // New accounts are automatically part of our groups (Realms). if (user.groups) { newuser.groups = user.groups; } // New accounts are automatically part of our groups (Realms).