diff --git a/src/routes/user.js b/src/routes/user.js index 32d055868..0a4a6c3b3 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -171,7 +171,7 @@ function requireAdmin(req, res, next) { function sendInvite(req, res, next) { assert.strictEqual(typeof req.params.userId, 'string'); - user.sendInvite(req.params.userId, function (error, result) { + user.sendInvite(req.params.userId, { invitor: req.user }, function (error, result) { if (error && error.reason === UserError.NOT_FOUND) return next(new HttpError(404, 'User not found')); if (error) return next(new HttpError(500, error)); diff --git a/src/user.js b/src/user.js index 9e5f381fa..8ba1e083f 100644 --- a/src/user.js +++ b/src/user.js @@ -600,8 +600,9 @@ function getOwner(callback) { }); } -function sendInvite(userId, callback) { +function sendInvite(userId, options, callback) { assert.strictEqual(typeof userId, 'string'); + assert.strictEqual(typeof options, 'object'); assert.strictEqual(typeof callback, 'function'); userdb.get(userId, function (error, userObject) { @@ -614,7 +615,7 @@ function sendInvite(userId, 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)); - mailer.sendInvite(userObject, null); + mailer.sendInvite(userObject, options.invitor || null); callback(null, userObject.resetToken); });