mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
handling of form completion in registration interstitial
This commit is contained in:
@@ -129,8 +129,35 @@ function addToApprovalQueue(req, userData, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
authenticationController.registerComplete = function(req, res, next) {
|
authenticationController.registerComplete = function(req, res, next) {
|
||||||
console.log(req.data);
|
// For the interstitials that respond, execute the callback with the form body
|
||||||
res.sendStatus(200);
|
plugins.fireHook('filter:register.interstitial', {
|
||||||
|
userData: req.session.registration,
|
||||||
|
interstitials: []
|
||||||
|
}, function(err, data) {
|
||||||
|
var callbacks = data.interstitials.reduce(function(memo, cur) {
|
||||||
|
if (cur.hasOwnProperty('callback') && typeof cur.callback === 'function') {
|
||||||
|
memo.push(async.apply(cur.callback, req.session.registration, req.body));
|
||||||
|
}
|
||||||
|
|
||||||
|
return memo;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async.parallel(callbacks, function(err) {
|
||||||
|
if (err) {
|
||||||
|
req.flash('error', err.message);
|
||||||
|
return res.redirect(nconf.get('relative_path') + '/register/complete');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear registration data in session
|
||||||
|
delete req.session.registration;
|
||||||
|
|
||||||
|
if (req.session.returnTo) {
|
||||||
|
res.redirect(req.session.returnTo);
|
||||||
|
} else {
|
||||||
|
res.redirect(nconf.get('relative_path') + '/');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
authenticationController.login = function(req, res, next) {
|
authenticationController.login = function(req, res, next) {
|
||||||
|
|||||||
@@ -194,6 +194,10 @@ Controllers.registerInterstitial = function(req, res, next) {
|
|||||||
userData: req.session.registration,
|
userData: req.session.registration,
|
||||||
interstitials: []
|
interstitials: []
|
||||||
}, function(err, data) {
|
}, function(err, data) {
|
||||||
|
if (!data.interstitials.length) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
var renders = data.interstitials.map(function(interstitial) {
|
var renders = data.interstitials.map(function(interstitial) {
|
||||||
return async.apply(req.app.render.bind(req.app), interstitial.template, interstitial.data)
|
return async.apply(req.app.render.bind(req.app), interstitial.template, interstitial.data)
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user