diff --git a/src/routes/user.js b/src/routes/user.js index 7d74abeec..ef8cb45d3 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -49,7 +49,7 @@ function createUser(req, res, next) { var password = generatePassword(8, true /* memorable */); var email = req.body.email; - user.create(username, password, email, false /* admin */, req.user /* creator */, function (error, user) { + user.create(username, password, email, false /* admin */, req.user /* creator */, true /* sendInvite */, function (error, user) { if (error && error.reason === UserError.BAD_USERNAME) return next(new HttpError(400, 'Invalid username')); if (error && error.reason === UserError.BAD_EMAIL) return next(new HttpError(400, 'Invalid email')); if (error && error.reason === UserError.BAD_PASSWORD) return next(new HttpError(400, 'Invalid password')); diff --git a/src/user.js b/src/user.js index 2b42ea1bd..cf9750bb6 100644 --- a/src/user.js +++ b/src/user.js @@ -113,12 +113,13 @@ function validateToken(token) { return null; } -function createUser(username, password, email, admin, invitor, callback) { +function createUser(username, password, email, admin, invitor, sendInvite, callback) { assert.strictEqual(typeof username, 'string'); assert.strictEqual(typeof password, 'string'); assert.strictEqual(typeof email, 'string'); assert.strictEqual(typeof admin, 'boolean'); assert(invitor || admin); + assert.strictEqual(typeof sendInvite, 'boolean'); assert.strictEqual(typeof callback, 'function'); var error = validateUsername(username); @@ -157,7 +158,7 @@ function createUser(username, password, email, admin, invitor, callback) { // only send welcome mail if user is not an admin. This is only the case for the first user! // The welcome email contains a link to create a new password - if (!user.admin) mailer.userAdded(user, invitor); + if (sendInvite) mailer.userAdded(user, invitor); }); }); }); @@ -389,7 +390,7 @@ function createOwner(username, password, email, callback) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); if (count !== 0) return callback(new UserError(UserError.ALREADY_EXISTS)); - createUser(username, password, email, true /* admin */, null /* invitor */, callback); + createUser(username, password, email, true /* admin */, null /* invitor */, false /* sendInvite */, callback); }); }