mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +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,22 +201,27 @@ authenticationController.login = function (req, res, next) { | ||||
| 	var loginWith = meta.config.allowLoginWith || 'username-email'; | ||||
| 	req.body.username = req.body.username.trim(); | ||||
|  | ||||
| 	if (req.body.username && utils.isEmailValid(req.body.username) && loginWith.includes('email')) { | ||||
| 		async.waterfall([ | ||||
| 			function (next) { | ||||
| 				user.getUsernameByEmail(req.body.username, next); | ||||
| 			}, | ||||
| 			function (username, next) { | ||||
| 				req.body.username = username || req.body.username; | ||||
| 				continueLogin(req, res, next); | ||||
| 			}, | ||||
| 		], next); | ||||
| 	} else if (loginWith.includes('username') && !validator.isEmail(req.body.username)) { | ||||
| 		continueLogin(req, res, next); | ||||
| 	} else { | ||||
| 		var err = '[[error:wrong-login-type-' + loginWith + ']]'; | ||||
| 		helpers.noScriptErrors(req, res, err, 500); | ||||
| 	} | ||||
| 	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) { | ||||
| 					user.getUsernameByEmail(req.body.username, next); | ||||
| 				}, | ||||
| 				function (username, next) { | ||||
| 					req.body.username = username || req.body.username; | ||||
| 					continueLogin(req, res, next); | ||||
| 				}, | ||||
| 			], next); | ||||
| 		} else if (loginWith.includes('username') && !validator.isEmail(req.body.username)) { | ||||
| 			continueLogin(req, res, next); | ||||
| 		} else { | ||||
| 			err = '[[error:wrong-login-type-' + loginWith + ']]'; | ||||
| 			helpers.noScriptErrors(req, res, err, 500); | ||||
| 		} | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| function continueLogin(req, res, next) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user