Do not succeed if mailbox name is already taken

This commit is contained in:
Johannes Zellner
2018-04-06 16:51:37 +02:00
parent 878940edae
commit 55d53ef311
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -908,7 +908,7 @@ function addMailbox(name, domain, userId, callback) {
if (error) return callback(error);
mailboxdb.addMailbox(name, domain, userId, mailboxdb.TYPE_USER, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new MailError(MailError.ALREADY_EXISTS, 'mailbox already exists'));
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new MailError(MailError.ALREADY_EXISTS, `mailbox ${name} already exists`));
if (error) return callback(new MailError(MailError.INTERNAL_ERROR, error));
callback(null);
+1 -1
View File
@@ -232,7 +232,7 @@ function addMailbox(req, res, next) {
mail.addMailbox(req.body.name, req.params.domain, req.body.userId, function (error) {
if (error && error.reason === MailError.NOT_FOUND) return next(new HttpError(404, error.message));
if (error && error.reason === MailError.ALREADY_EXISTS) return next(new HttpSuccess(201, {}));
if (error && error.reason === MailError.ALREADY_EXISTS) return next(new HttpError(409, error.message));
if (error && error.reason === MailError.BAD_FIELD) return next(new HttpError(400, error.message));
if (error) return next(new HttpError(500, error));