do not crash on duplicate email

This commit is contained in:
Girish Ramakrishnan
2016-04-13 14:47:35 -07:00
parent 389d2be82d
commit c24d7e7b3c
2 changed files with 2 additions and 2 deletions

View File

@@ -100,7 +100,9 @@ function update(req, res, next) {
if (error) return next(new HttpError(500, error));
user.update(req.params.userId, result.username, req.body.email || result.email, req.body.displayName || result.displayName, function (error) {
if (error && error.reason === UserError.BAD_USERNAME) return next(new HttpError(400, error.message));
if (error && error.reason === UserError.BAD_EMAIL) return next(new HttpError(400, error.message));
if (error && error.reason === UserError.ALREADY_EXISTS) return next(new HttpError(409, 'Already exists'));
if (error && error.reason === UserError.NOT_FOUND) return next(new HttpError(404, 'User not found'));
if (error) return next(new HttpError(500, error));