From 2161f0d473e89aabddd09db27fa3ef2f540fa165 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Thu, 27 Oct 2016 10:52:25 -0500 Subject: [PATCH] Allow plugins to affect whether a registration goes into the queue --- src/controllers/authentication.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 86ff7563f3..260a0e7281 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -56,25 +56,30 @@ authenticationController.register = function (req, res, next) { user.isPasswordValid(userData.password, next); }, function (next) { - res.locals.processLogin = true; // set it to false in plugin if you wish to just register only - plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData}, next); - }, - function (data, next) { if (registrationType === 'normal' || registrationType === 'invite-only' || registrationType === 'admin-invite-only') { - registerAndLoginUser(req, res, userData, next); + next(null, false); } else if (registrationType === 'admin-approval') { - addToApprovalQueue(req, userData, next); + next(null, true); } else if (registrationType === 'admin-approval-ip') { db.sortedSetCard('ip:' + req.ip + ':uid', function (err, count) { if (err) { next(err); - } else if (count) { - addToApprovalQueue(req, userData, next); } else { - registerAndLoginUser(req, res, userData, next); + next(null, !!count); } }); } + }, + function (queue, next) { + res.locals.processLogin = true; // set it to false in plugin if you wish to just register only + plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData, queue: queue}, next); + }, + function (data, next) { + if (data.queue) { + addToApprovalQueue(req, userData, next); + } else { + registerAndLoginUser(req, res, userData, next); + } } ], function (err, data) { if (err) {