test that user.del removed mailbox and aliases

This commit is contained in:
Girish Ramakrishnan
2016-09-26 00:14:03 -07:00
parent d92e99a092
commit a8d57bb036
2 changed files with 22 additions and 4 deletions

View File

@@ -285,7 +285,7 @@ function removeUser(userId, auditSource, callback) {
eventlog.add(eventlog.ACTION_USER_REMOVE, auditSource, { userId: userId });
if (user.username) mailboxdb.delByOwnerId(user.id, callback); else callback();
asyncIf(!!user.username, mailboxdb.delByOwnerId.bind(null, user.id), callback);
mailer.userRemoved(user);
});
@@ -588,6 +588,8 @@ function setAliases(userId, aliases, callback) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
if (!user.username) return new UserError(UserError.BAD_FIELD, 'Username must be set before settings aliases');
mailboxdb.setAliasesByName(user.username, aliases, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new UserError(UserError.ALREADY_EXISTS, error.message));
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));