Node.js based forum software built for the modern web
WIP registration interstitial
Julian Lam0ba0001f75f0
diff --git a/public/language/en_GB/register.json b/public/language/en_GB/register.jsonindex dcbd4bb03a..f6ee52afd7 100644--- a/public/language/en_GB/register.json+++ b/public/language/en_GB/register.json@@ -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."}\ No newline at end of filediff --git a/src/controllers/authentication.js b/src/controllers/authentication.jsindex 2cc635b80c..f4729cffb3 100644--- a/src/controllers/authentication.js+++ b/src/controllers/authentication.js@@ -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);},diff --git a/src/controllers/index.js b/src/controllers/index.jsindex 26b7527ce9..a18f3695d5 100644--- a/src/controllers/index.js+++ b/src/controllers/index.js@@ -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,diff --git a/src/routes/index.js b/src/routes/index.jsindex 626b480db1..7266629e1a 100644--- a/src/routes/index.js+++ b/src/routes/index.js@@ -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);