Skip to content

Node.js based forum software built for the modern web

feat: allow override of local fns in login controller, 400 instead of 500 for wrong login type [breaking]

Julian Lam1cf0032d9fb7
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);
}
});
};