mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
@@ -17,7 +17,7 @@ var Password = require('../password');
|
||||
|
||||
var authenticationController = {};
|
||||
|
||||
authenticationController.register = function(req, res, next) {
|
||||
authenticationController.register = function (req, res, next) {
|
||||
var registrationType = meta.config.registrationType || 'normal';
|
||||
|
||||
if (registrationType === 'disabled') {
|
||||
@@ -33,14 +33,14 @@ authenticationController.register = function(req, res, next) {
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
if (registrationType === 'invite-only' || registrationType === 'admin-invite-only') {
|
||||
user.verifyInvitation(userData, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
function (next) {
|
||||
if (!userData.email) {
|
||||
return next(new Error('[[error:invalid-email]]'));
|
||||
}
|
||||
@@ -55,17 +55,17 @@ authenticationController.register = function(req, res, 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);
|
||||
},
|
||||
function(data, next) {
|
||||
function (data, next) {
|
||||
if (registrationType === 'normal' || registrationType === 'invite-only' || registrationType === 'admin-invite-only') {
|
||||
registerAndLoginUser(req, res, userData, next);
|
||||
} else if (registrationType === 'admin-approval') {
|
||||
addToApprovalQueue(req, userData, next);
|
||||
} else if (registrationType === 'admin-approval-ip') {
|
||||
db.sortedSetCard('ip:' + req.ip + ':uid', function(err, count) {
|
||||
db.sortedSetCard('ip:' + req.ip + ':uid', function (err, count) {
|
||||
if (err) {
|
||||
next(err);
|
||||
} else if (count) {
|
||||
@@ -76,7 +76,7 @@ authenticationController.register = function(req, res, next) {
|
||||
});
|
||||
}
|
||||
}
|
||||
], function(err, data) {
|
||||
], function (err, data) {
|
||||
if (err) {
|
||||
return res.status(400).send(err.message);
|
||||
}
|
||||
@@ -92,11 +92,11 @@ authenticationController.register = function(req, res, next) {
|
||||
function registerAndLoginUser(req, res, userData, callback) {
|
||||
var uid;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
plugins.fireHook('filter:register.interstitial', {
|
||||
userData: userData,
|
||||
interstitials: []
|
||||
}, function(err, data) {
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -113,10 +113,10 @@ function registerAndLoginUser(req, res, userData, callback) {
|
||||
}
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
function (next) {
|
||||
user.create(userData, next);
|
||||
},
|
||||
function(_uid, next) {
|
||||
function (_uid, next) {
|
||||
uid = _uid;
|
||||
if (res.locals.processLogin) {
|
||||
authenticationController.doLogin(req, uid, next);
|
||||
@@ -124,7 +124,7 @@ function registerAndLoginUser(req, res, userData, callback) {
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
function (next) {
|
||||
user.deleteInvitationKey(userData.email);
|
||||
plugins.fireHook('filter:register.complete', {uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/'}, next);
|
||||
}
|
||||
@@ -133,27 +133,27 @@ function registerAndLoginUser(req, res, userData, callback) {
|
||||
|
||||
function addToApprovalQueue(req, userData, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
userData.ip = req.ip;
|
||||
user.addToApprovalQueue(userData, next);
|
||||
},
|
||||
function(next) {
|
||||
function (next) {
|
||||
next(null, {message: '[[register:registration-added-to-queue]]'});
|
||||
}
|
||||
], callback);
|
||||
}
|
||||
|
||||
authenticationController.registerComplete = function(req, res, next) {
|
||||
authenticationController.registerComplete = function (req, res, next) {
|
||||
// For the interstitials that respond, execute the callback with the form body
|
||||
plugins.fireHook('filter:register.interstitial', {
|
||||
userData: req.session.registration,
|
||||
interstitials: []
|
||||
}, function(err, data) {
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
var callbacks = data.interstitials.reduce(function(memo, cur) {
|
||||
var callbacks = data.interstitials.reduce(function (memo, cur) {
|
||||
if (cur.hasOwnProperty('callback') && typeof cur.callback === 'function') {
|
||||
memo.push(async.apply(cur.callback, req.session.registration, req.body));
|
||||
}
|
||||
@@ -161,7 +161,7 @@ authenticationController.registerComplete = function(req, res, next) {
|
||||
return memo;
|
||||
}, []);
|
||||
|
||||
var done = function() {
|
||||
var done = function () {
|
||||
delete req.session.registration;
|
||||
|
||||
if (req.session.returnTo) {
|
||||
@@ -171,7 +171,7 @@ authenticationController.registerComplete = function(req, res, next) {
|
||||
}
|
||||
};
|
||||
|
||||
async.parallel(callbacks, function(err) {
|
||||
async.parallel(callbacks, function (err) {
|
||||
if (err) {
|
||||
req.flash('error', err.message);
|
||||
return res.redirect(nconf.get('relative_path') + '/register/complete');
|
||||
@@ -188,14 +188,14 @@ authenticationController.registerComplete = function(req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
authenticationController.registerAbort = function(req, res) {
|
||||
authenticationController.registerAbort = function (req, res) {
|
||||
// End the session and redirect to home
|
||||
req.session.destroy(function() {
|
||||
req.session.destroy(function () {
|
||||
res.redirect(nconf.get('relative_path') + '/');
|
||||
});
|
||||
};
|
||||
|
||||
authenticationController.login = function(req, res, next) {
|
||||
authenticationController.login = function (req, res, next) {
|
||||
// Handle returnTo data
|
||||
if (req.body.hasOwnProperty('returnTo') && !req.session.returnTo) {
|
||||
// As req.body is data obtained via userland, it is untrusted, restrict to internal links only
|
||||
@@ -212,7 +212,7 @@ authenticationController.login = function(req, res, next) {
|
||||
var loginWith = meta.config.allowLoginWith || 'username-email';
|
||||
|
||||
if (req.body.username && utils.isEmailValid(req.body.username) && loginWith.indexOf('email') !== -1) {
|
||||
user.getUsernameByEmail(req.body.username, function(err, username) {
|
||||
user.getUsernameByEmail(req.body.username, function (err, username) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ authenticationController.login = function(req, res, next) {
|
||||
};
|
||||
|
||||
function continueLogin(req, res, next) {
|
||||
passport.authenticate('local', function(err, userData, info) {
|
||||
passport.authenticate('local', function (err, userData, info) {
|
||||
if (err) {
|
||||
return res.status(403).send(err.message);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ function continueLogin(req, res, next) {
|
||||
if (passwordExpiry && passwordExpiry < Date.now()) {
|
||||
winston.verbose('[auth] Triggering password reset for uid ' + userData.uid + ' due to password policy');
|
||||
req.session.passwordExpired = true;
|
||||
user.reset.generate(userData.uid, function(err, code) {
|
||||
user.reset.generate(userData.uid, function (err, code) {
|
||||
if (err) {
|
||||
return res.status(403).send(err.message);
|
||||
}
|
||||
@@ -263,7 +263,7 @@ function continueLogin(req, res, next) {
|
||||
res.status(200).send(nconf.get('relative_path') + '/reset/' + code);
|
||||
});
|
||||
} else {
|
||||
authenticationController.doLogin(req, userData.uid, function(err) {
|
||||
authenticationController.doLogin(req, userData.uid, function (err) {
|
||||
if (err) {
|
||||
return res.status(403).send(err.message);
|
||||
}
|
||||
@@ -281,12 +281,12 @@ function continueLogin(req, res, next) {
|
||||
})(req, res, next);
|
||||
}
|
||||
|
||||
authenticationController.doLogin = function(req, uid, callback) {
|
||||
authenticationController.doLogin = function (req, uid, callback) {
|
||||
if (!uid) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
req.login({uid: uid}, function(err) {
|
||||
req.login({uid: uid}, function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -295,8 +295,8 @@ authenticationController.doLogin = function(req, uid, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
authenticationController.onSuccessfulLogin = function(req, uid, callback) {
|
||||
callback = callback || function() {};
|
||||
authenticationController.onSuccessfulLogin = function (req, uid, callback) {
|
||||
callback = callback || function () {};
|
||||
var uuid = utils.generateUUID();
|
||||
req.session.meta = {};
|
||||
|
||||
@@ -326,7 +326,7 @@ authenticationController.onSuccessfulLogin = function(req, uid, callback) {
|
||||
function (next) {
|
||||
user.updateLastOnlineTime(uid, next);
|
||||
}
|
||||
], function(err) {
|
||||
], function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -335,7 +335,7 @@ authenticationController.onSuccessfulLogin = function(req, uid, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
authenticationController.localLogin = function(req, username, password, next) {
|
||||
authenticationController.localLogin = function (req, username, password, next) {
|
||||
if (!username) {
|
||||
return next(new Error('[[error:invalid-username]]'));
|
||||
}
|
||||
@@ -359,13 +359,13 @@ authenticationController.localLogin = function(req, username, password, next) {
|
||||
},
|
||||
function (next) {
|
||||
async.parallel({
|
||||
userData: function(next) {
|
||||
userData: function (next) {
|
||||
db.getObjectFields('user:' + uid, ['password', 'passwordExpiry'], next);
|
||||
},
|
||||
isAdmin: function(next) {
|
||||
isAdmin: function (next) {
|
||||
user.isAdministrator(uid, next);
|
||||
},
|
||||
banned: function(next) {
|
||||
banned: function (next) {
|
||||
user.isBanned(uid, next);
|
||||
}
|
||||
}, next);
|
||||
@@ -383,7 +383,7 @@ authenticationController.localLogin = function(req, username, password, next) {
|
||||
}
|
||||
if (result.banned) {
|
||||
// Retrieve ban reason and show error
|
||||
return user.getLatestBanInfo(uid, function(err, banInfo) {
|
||||
return user.getLatestBanInfo(uid, function (err, banInfo) {
|
||||
if (err) {
|
||||
next(err);
|
||||
} else if (banInfo.reason) {
|
||||
@@ -406,10 +406,10 @@ authenticationController.localLogin = function(req, username, password, next) {
|
||||
], next);
|
||||
};
|
||||
|
||||
authenticationController.logout = function(req, res, next) {
|
||||
authenticationController.logout = function (req, res, next) {
|
||||
if (req.user && parseInt(req.user.uid, 10) > 0 && req.sessionID) {
|
||||
var uid = parseInt(req.user.uid, 10);
|
||||
user.auth.revokeSession(req.sessionID, uid, function(err) {
|
||||
user.auth.revokeSession(req.sessionID, uid, function (err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -418,7 +418,7 @@ authenticationController.logout = function(req, res, next) {
|
||||
|
||||
user.setUserField(uid, 'lastonline', Date.now() - 300000);
|
||||
|
||||
plugins.fireHook('static:user.loggedOut', {req: req, res: res, uid: uid}, function() {
|
||||
plugins.fireHook('static:user.loggedOut', {req: req, res: res, uid: uid}, function () {
|
||||
res.status(200).send('');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user