mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	closes #4157
This commit is contained in:
		@@ -55,11 +55,12 @@ authenticationController.register = function(req, res, next) {
 | 
				
			|||||||
			user.isPasswordValid(userData.password, next);
 | 
								user.isPasswordValid(userData.password, next);
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		function(next) {
 | 
							function(next) {
 | 
				
			||||||
 | 
								res.locals.processLogin = true;	// set it to false in plugin if you wish to just register only
 | 
				
			||||||
			plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData}, next);
 | 
								plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData}, next);
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		function(data, next) {
 | 
							function(data, next) {
 | 
				
			||||||
			if (registrationType === 'normal' || registrationType === 'invite-only') {
 | 
								if (registrationType === 'normal' || registrationType === 'invite-only') {
 | 
				
			||||||
				registerAndLoginUser(req, userData, next);
 | 
									registerAndLoginUser(req, res, userData, next);
 | 
				
			||||||
			} else if (registrationType === 'admin-approval') {
 | 
								} else if (registrationType === 'admin-approval') {
 | 
				
			||||||
				addToApprovalQueue(req, userData, next);
 | 
									addToApprovalQueue(req, userData, next);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -77,7 +78,7 @@ authenticationController.register = function(req, res, next) {
 | 
				
			|||||||
	});
 | 
						});
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function registerAndLoginUser(req, userData, callback) {
 | 
					function registerAndLoginUser(req, res, userData, callback) {
 | 
				
			||||||
	var uid;
 | 
						var uid;
 | 
				
			||||||
	async.waterfall([
 | 
						async.waterfall([
 | 
				
			||||||
		function(next) {
 | 
							function(next) {
 | 
				
			||||||
@@ -85,13 +86,15 @@ function registerAndLoginUser(req, userData, callback) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		function(_uid, next) {
 | 
							function(_uid, next) {
 | 
				
			||||||
			uid = _uid;
 | 
								uid = _uid;
 | 
				
			||||||
			req.login({uid: uid}, next);
 | 
								if (res.locals.processLogin === true) {
 | 
				
			||||||
 | 
									user.logIP(uid, req.ip);
 | 
				
			||||||
 | 
									req.login({uid: uid}, next);
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									next();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		function(next) {
 | 
							function(next) {
 | 
				
			||||||
			user.logIP(uid, req.ip);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			user.deleteInvitation(userData.email);
 | 
								user.deleteInvitation(userData.email);
 | 
				
			||||||
 | 
					 | 
				
			||||||
			plugins.fireHook('filter:register.complete', {uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/'}, next);
 | 
								plugins.fireHook('filter:register.complete', {uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/'}, next);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	], callback);
 | 
						], callback);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user