intersititial test

This commit is contained in:
barisusakli
2017-02-28 16:42:10 +03:00
parent 8a0cf6c0ac
commit 2e47cf4db3
3 changed files with 85 additions and 27 deletions

View File

@@ -201,37 +201,35 @@ Controllers.registerInterstitial = function (req, res, next) {
return res.redirect(nconf.get('relative_path') + '/register');
}
plugins.fireHook('filter:register.interstitial', {
userData: req.session.registration,
interstitials: [],
}, function (err, data) {
if (err) {
return next(err);
}
if (!data.interstitials.length) {
// No interstitials, redirect to home
delete req.session.registration;
return res.redirect('/');
}
var renders = data.interstitials.map(function (interstitial) {
return async.apply(req.app.render.bind(req.app), interstitial.template, interstitial.data || {});
});
var errors = req.flash('error');
async.parallel(renders, function (err, sections) {
if (err) {
return next(err);
async.waterfall([
function (next) {
plugins.fireHook('filter:register.interstitial', {
userData: req.session.registration,
interstitials: [],
}, next);
},
function (data, next) {
if (!data.interstitials.length) {
// No interstitials, redirect to home
delete req.session.registration;
return res.redirect('/');
}
var renders = data.interstitials.map(function (interstitial) {
return async.apply(req.app.render.bind(req.app), interstitial.template, interstitial.data || {});
});
async.parallel(renders, next);
},
function (sections) {
var errors = req.flash('error');
res.render('registerComplete', {
title: '[[pages:registration-complete]]',
errors: errors,
sections: sections,
});
});
});
},
], next);
};
Controllers.compose = function (req, res, next) {