From 9bf94ad50ff9a408adf23357f51dcf403d4580b2 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 26 Feb 2021 09:58:48 -0500 Subject: [PATCH] fix: allow interstitial callbacks to be functional (no cb required) --- src/controllers/authentication.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index dece1978e9..a96af6d45f 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -150,7 +150,14 @@ authenticationController.registerComplete = function (req, res, next) { const callbacks = data.interstitials.reduce((memo, cur) => { if (cur.hasOwnProperty('callback') && typeof cur.callback === 'function') { req.body.files = req.files; - memo.push(cur.callback && cur.callback.constructor && cur.callback.constructor.name === 'AsyncFunction' ? cur.callback : util.promisify(cur.callback)); + if ( + (cur.callback.constructor && cur.callback.constructor.name === 'AsyncFunction') || + cur.callback.length === 2 // non-async function w/o callback + ) { + memo.push(cur.callback); + } else { + memo.push(util.promisify(cur.callback)); + } } return memo;