Add displayName to create user and activate routes

This commit is contained in:
girish@cloudron.io
2016-01-19 23:34:49 -08:00
parent 67b94c7fde
commit ee705eb979
7 changed files with 39 additions and 20 deletions

View File

@@ -46,13 +46,15 @@ function createUser(req, res, next) {
if (typeof req.body.username !== 'string') return next(new HttpError(400, 'username must be string'));
if (typeof req.body.email !== 'string') return next(new HttpError(400, 'email must be string'));
if (typeof req.body.invite !== 'boolean') return next(new HttpError(400, 'invite must be boolean'));
if ('displayName' in req.body && req.body.displayName !== 'string') return next(new HttpError(400, 'displayName must be string'));
var username = req.body.username;
var password = generatePassword(8, true /* memorable */);
var email = req.body.email;
var sendInvite = req.body.invite;
var displayName = req.body.displayName || '';
user.create(username, password, email, false /* admin */, req.user /* creator */, sendInvite, function (error, user) {
user.create(username, password, email, displayName, false /* admin */, req.user /* creator */, 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'));