mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
feat: adding filter:login.check and loginFormEntry[] for the filter:login.build hook (#7861)
* adding filter:login.check and loginFormEntry[] for the filter:login.build hook, related to nodebb-plugin-spam-be-gone/issues/32 * do not exceed 50 lines per function * spam-be-gone@0.6.4
This commit is contained in:
@@ -201,6 +201,10 @@ authenticationController.login = function (req, res, next) {
|
||||
var loginWith = meta.config.allowLoginWith || 'username-email';
|
||||
req.body.username = req.body.username.trim();
|
||||
|
||||
plugins.fireHook('filter:login.check', { req: req, res: res, userData: req.body }, (err) => {
|
||||
if (err) {
|
||||
return helpers.noScriptErrors(req, res, err.message, 403);
|
||||
}
|
||||
if (req.body.username && utils.isEmailValid(req.body.username) && loginWith.includes('email')) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
@@ -214,9 +218,10 @@ authenticationController.login = function (req, res, next) {
|
||||
} else if (loginWith.includes('username') && !validator.isEmail(req.body.username)) {
|
||||
continueLogin(req, res, next);
|
||||
} else {
|
||||
var err = '[[error:wrong-login-type-' + loginWith + ']]';
|
||||
err = '[[error:wrong-login-type-' + loginWith + ']]';
|
||||
helpers.noScriptErrors(req, res, err, 500);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function continueLogin(req, res, next) {
|
||||
|
||||
@@ -96,7 +96,7 @@ Controllers.reset = function (req, res, next) {
|
||||
};
|
||||
|
||||
Controllers.login = function (req, res, next) {
|
||||
var data = {};
|
||||
var data = { loginFormEntry: [] };
|
||||
var loginStrategies = require('../routes/authentication').getLoginStrategies();
|
||||
var registrationType = meta.config.registrationType || 'normal';
|
||||
var allowLoginWith = (meta.config.allowLoginWith || 'username-email');
|
||||
|
||||
Reference in New Issue
Block a user