From 1cf0032d9fb74396d0778a2e30ada9f03fdb9223 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 7 Jan 2021 12:16:35 -0500 Subject: [PATCH] feat: allow override of local fns in login controller, 400 instead of 500 for wrong login type [breaking] --- src/controllers/authentication.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index eec386bb8f..48ed0393e6 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -226,7 +226,7 @@ authenticationController.login = function (req, res, next) { plugins.hooks.fire('filter:login.check', { req: req, res: res, userData: req.body }, (err) => { if (err) { - return helpers.noScriptErrors(req, res, err.message, 403); + return (res.locals.noScriptErrors || helpers.noScriptErrors)(req, res, err.message, 403); } if (req.body.username && utils.isEmailValid(req.body.username) && loginWith.includes('email')) { async.waterfall([ @@ -235,14 +235,14 @@ authenticationController.login = function (req, res, next) { }, function (username, next) { req.body.username = username || req.body.username; - continueLogin(req, res, next); + (res.locals.continueLogin || continueLogin)(req, res, next); }, ], next); } else if (loginWith.includes('username') && !validator.isEmail(req.body.username)) { - continueLogin(req, res, next); + (res.locals.continueLogin || continueLogin)(req, res, next); } else { err = '[[error:wrong-login-type-' + loginWith + ']]'; - helpers.noScriptErrors(req, res, err, 500); + (res.locals.noScriptErrors || helpers.noScriptErrors)(req, res, err, 400); } }); };