Adjust api to set a flag if invitiation should be sent on user creation

This commit is contained in:
Johannes Zellner
2016-01-18 13:48:10 +01:00
parent 2edd434474
commit 8ac27b9dc7
2 changed files with 5 additions and 4 deletions

View File

@@ -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);
});
}