From e9ed7f0bb3555f80aaa916881cde97e973ed69f5 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 6 Apr 2018 10:16:26 -0400 Subject: [PATCH] closes #6435 --- src/controllers/authentication.js | 15 +++++++++++---- src/controllers/index.js | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 88d0ec5b49..f8537da085 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -152,7 +152,12 @@ authenticationController.registerComplete = function (req, res, next) { 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)); + memo.push(function (next) { + cur.callback(req.session.registration, req.body, function (err) { + // Pass error as second argument so all callbacks are executed + next(null, err); + }); + }); } return memo; @@ -170,9 +175,11 @@ authenticationController.registerComplete = function (req, res, next) { } }; - async.parallel(callbacks, function (err) { - if (err) { - req.flash('error', err.message); + async.parallel(callbacks, function (_blank, err) { + if (err.length) { + req.flash('errors', err.filter(Boolean).map(function (err) { + return err.message; + })); return res.redirect(nconf.get('relative_path') + '/register/complete'); } diff --git a/src/controllers/index.js b/src/controllers/index.js index 550130ce92..292d892767 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -207,7 +207,7 @@ Controllers.registerInterstitial = function (req, res, next) { async.parallel(renders, next); }, function (sections) { - var errors = req.flash('error'); + var errors = req.flash('errors'); res.render('registerComplete', { title: '[[pages:registration-complete]]', errors: errors,