autocreate mailbox when username is available

This commit is contained in:
Girish Ramakrishnan
2016-05-29 19:14:01 -07:00
parent 68a3862ee5
commit ec71390d0b
+5
View File
@@ -31,6 +31,7 @@ var assert = require('assert'),
GroupError = groups.GroupError,
hat = require('hat'),
mailer = require('./mailer.js'),
mailboxes = require('./mailboxes.js'),
tokendb = require('./tokendb.js'),
userdb = require('./userdb.js'),
util = require('util'),
@@ -43,6 +44,8 @@ var CRYPTO_SALT_SIZE = 64; // 512-bit salt
var CRYPTO_ITERATIONS = 10000; // iterations
var CRYPTO_KEY_LENGTH = 512; // bits
var NOOP_CALLBACK = function (error) { if (error) debug(error); };
// http://dustinsenos.com/articles/customErrorsInNode
// http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
function UserError(reason, errorOrMessage) {
@@ -175,6 +178,7 @@ function createUser(username, password, email, displayName, auditSource, options
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
eventlog.add(eventlog.ACTION_USER_ADD, auditSource, { userId: user.id, email: user.email });
if (username) mailboxes.add(username, NOOP_CALLBACK);
callback(null, user);
@@ -336,6 +340,7 @@ function updateUser(userId, username, email, displayName, auditSource, callback)
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
eventlog.add(eventlog.ACTION_USER_UPDATE, auditSource, { userId: userId });
if (username) mailboxes.add(username, NOOP_CALLBACK);
callback(null);
});