WIP registration interstitial

v1.18.x
Julian Lam 9 years ago committed by Julian Lam
parent 871a247840
commit 0ba0001f75

@ -15,5 +15,6 @@
"alternative_registration": "Alternative Registration",
"terms_of_use": "Terms of Use",
"agree_to_terms_of_use": "I agree to the Terms of Use",
"registration-added-to-queue": "Your registration has been added to the approval queue. You will receive an email when it is accepted by an administrator."
"registration-added-to-queue": "Your registration has been added to the approval queue. You will receive an email when it is accepted by an administrator.",
"interstitial.intro": "We require some additional information before we can create your account."
}

@ -81,6 +81,23 @@ authenticationController.register = function(req, res, next) {
function registerAndLoginUser(req, res, userData, callback) {
var uid;
async.waterfall([
function(next) {
plugins.fireHook('filter:register.interstitial', {
userData: userData,
interstitials: []
}, function(err, data) {
// If interstitials are found, save registration attempt into session and abort
var deferRegistration = data.interstitials.length;
deferRegistration = true;
if (!deferRegistration) {
return next();
} else {
req.session.registration = userData;
return res.json({ referrer: nconf.get('relative_path') + '/register/complete' });
}
});
},
function(next) {
user.create(userData, next);
},

@ -185,6 +185,27 @@ Controllers.register = function(req, res, next) {
});
};
Controllers.registerInterstitial = function(req, res, next) {
if (!req.session.hasOwnProperty('registration')) {
return res.redirect(nconf.get('relative_path') + '/register');
}
plugins.fireHook('filter:register.interstitial', {
userData: req.session.registration,
interstitials: []
}, function(err, data) {
var renders = data.interstitials.map(function(interstitial) {
return async.apply(req.app.render.bind(req.app), interstitial.template, interstitial.data)
});
async.parallel(renders, function(err, sections) {
res.render('registerComplete', {
sections: sections
});
});
});
};
Controllers.compose = function(req, res, next) {
plugins.fireHook('filter:composer.build', {
req: req,

@ -28,6 +28,7 @@ function mainRoutes(app, middleware, controllers) {
setupPageRoute(app, '/login', middleware, loginRegisterMiddleware, controllers.login);
setupPageRoute(app, '/register', middleware, loginRegisterMiddleware, controllers.register);
setupPageRoute(app, '/register/complete', middleware, loginRegisterMiddleware, controllers.registerInterstitial);
setupPageRoute(app, '/compose', middleware, [], controllers.compose);
setupPageRoute(app, '/confirm/:code', middleware, [], controllers.confirmEmail);
setupPageRoute(app, '/outgoing', middleware, [], controllers.outgoing);

Loading…
Cancel
Save