From cd4a204f999d5ef5bac4557f03d4c15abebfdce3 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 17 Mar 2014 14:56:00 -0400 Subject: [PATCH 1/2] closes #963 --- src/routes/authentication.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index b2ffd4f73d..28f46ec7b5 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -59,14 +59,29 @@ }); })(req, res, next); } - + function register(req, res) { if(meta.config.allowRegistration !== undefined && parseInt(meta.config.allowRegistration, 10) === 0) { return res.send(403); } - user.create({username: req.body.username, password: req.body.password, email: req.body.email, ip: req.ip}, function(err, uid) { - if (err === null && uid) { + var userData = { + username: req.body.username, + password: req.body.password, + email: req.body.email, + ip: req.ip + }; + + plugins.fireHook('filter:register.check', userData, function(err, userData) { + if (err) { + res.redirect(nconf.get('relative_path') + '/register'); + } + + user.create(userData, function(err, uid) { + if (err || !uid) { + res.redirect(nconf.get('relative_path') + '/register'); + } + req.login({ uid: uid }, function() { @@ -79,9 +94,7 @@ res.redirect(nconf.get('relative_path') + '/'); } }); - } else { - res.redirect(nconf.get('relative_path') + '/register'); - } + }); }); } From 76d8f19e73041560de9914bc0b76314231b5e9fa Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 17 Mar 2014 14:56:32 -0400 Subject: [PATCH 2/2] forgot to return #963 --- src/routes/authentication.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index 28f46ec7b5..1b35d78d29 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -74,12 +74,12 @@ plugins.fireHook('filter:register.check', userData, function(err, userData) { if (err) { - res.redirect(nconf.get('relative_path') + '/register'); + return res.redirect(nconf.get('relative_path') + '/register'); } user.create(userData, function(err, uid) { if (err || !uid) { - res.redirect(nconf.get('relative_path') + '/register'); + return res.redirect(nconf.get('relative_path') + '/register'); } req.login({