Skip to content

Node.js based forum software built for the modern web

Allow plugins to affect whether a registration goes into the queue

Ben Lubar2161f0d473e8
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) {