mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
merge
This commit is contained in:
@@ -17,7 +17,7 @@ var translator = require('../translator');
|
||||
|
||||
var sockets = require('../socket.io');
|
||||
|
||||
var authenticationController = {};
|
||||
var authenticationController = module.exports;
|
||||
|
||||
authenticationController.register = function (req, res) {
|
||||
var registrationType = meta.config.registrationType || 'normal';
|
||||
@@ -345,21 +345,21 @@ authenticationController.localLogin = function (req, username, password, next) {
|
||||
var uid;
|
||||
var userData = {};
|
||||
|
||||
if (!password || !utils.isPasswordValid(password)) {
|
||||
return next(new Error('[[error:invalid-password]]'));
|
||||
}
|
||||
|
||||
if (password.length > 4096) {
|
||||
return next(new Error('[[error:password-too-long]]'));
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.isPasswordValid(password, next);
|
||||
},
|
||||
function (next) {
|
||||
user.getUidByUserslug(userslug, next);
|
||||
},
|
||||
function (_uid, next) {
|
||||
if (!_uid) {
|
||||
return next(new Error('[[error:no-user]]'));
|
||||
}
|
||||
uid = _uid;
|
||||
user.auth.logAttempt(uid, req.ip, next);
|
||||
},
|
||||
function (next) {
|
||||
|
||||
async.parallel({
|
||||
userData: function (next) {
|
||||
db.getObjectFields('user:' + uid, ['password', 'passwordExpiry'], next);
|
||||
@@ -381,19 +381,18 @@ authenticationController.localLogin = function (req, username, password, next) {
|
||||
return next(new Error('[[error:local-login-disabled]]'));
|
||||
}
|
||||
|
||||
if (!userData || !userData.password) {
|
||||
return next(new Error('[[error:invalid-user-data]]'));
|
||||
}
|
||||
|
||||
if (result.banned) {
|
||||
return banUser(uid, next);
|
||||
}
|
||||
|
||||
user.auth.logAttempt(uid, req.ip, next);
|
||||
},
|
||||
function (next) {
|
||||
Password.compare(password, userData.password, next);
|
||||
},
|
||||
function (passwordMatch, next) {
|
||||
if (!passwordMatch) {
|
||||
return next(new Error('[[error:invalid-password]]'));
|
||||
return next(new Error('[[error:invalid-login-credentials]]'));
|
||||
}
|
||||
user.auth.clearLoginAttempts(uid);
|
||||
next(null, userData, '[[success:authentication-successful]]');
|
||||
@@ -447,5 +446,3 @@ function banUser(uid, next) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = authenticationController;
|
||||
|
||||
Reference in New Issue
Block a user