mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
on login display invalid-login-credentials
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
"invalid-title": "Invalid title",
|
"invalid-title": "Invalid title",
|
||||||
"invalid-user-data": "Invalid User Data",
|
"invalid-user-data": "Invalid User Data",
|
||||||
"invalid-password": "Invalid Password",
|
"invalid-password": "Invalid Password",
|
||||||
|
"invalid-login-credentials": "Invalid login credentials",
|
||||||
"invalid-username-or-password": "Please specify both a username and password",
|
"invalid-username-or-password": "Please specify both a username and password",
|
||||||
"invalid-search-term": "Invalid search term",
|
"invalid-search-term": "Invalid search term",
|
||||||
"csrf-invalid": "We were unable to log you in, likely due to an expired session. Please try again",
|
"csrf-invalid": "We were unable to log you in, likely due to an expired session. Please try again",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ var Password = require('../password');
|
|||||||
|
|
||||||
var sockets = require('../socket.io');
|
var sockets = require('../socket.io');
|
||||||
|
|
||||||
var authenticationController = {};
|
var authenticationController = module.exports;
|
||||||
|
|
||||||
authenticationController.register = function (req, res) {
|
authenticationController.register = function (req, res) {
|
||||||
var registrationType = meta.config.registrationType || 'normal';
|
var registrationType = meta.config.registrationType || 'normal';
|
||||||
@@ -357,13 +357,8 @@ authenticationController.localLogin = function (req, username, password, next) {
|
|||||||
user.getUidByUserslug(userslug, next);
|
user.getUidByUserslug(userslug, next);
|
||||||
},
|
},
|
||||||
function (_uid, next) {
|
function (_uid, next) {
|
||||||
if (!_uid) {
|
|
||||||
return next(new Error('[[error:no-user]]'));
|
|
||||||
}
|
|
||||||
uid = _uid;
|
uid = _uid;
|
||||||
user.auth.logAttempt(uid, req.ip, next);
|
|
||||||
},
|
|
||||||
function (next) {
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
userData: function (next) {
|
userData: function (next) {
|
||||||
db.getObjectFields('user:' + uid, ['password', 'passwordExpiry'], next);
|
db.getObjectFields('user:' + uid, ['password', 'passwordExpiry'], next);
|
||||||
@@ -384,9 +379,7 @@ authenticationController.localLogin = function (req, username, password, next) {
|
|||||||
if (!result.isAdmin && parseInt(meta.config.allowLocalLogin, 10) === 0) {
|
if (!result.isAdmin && parseInt(meta.config.allowLocalLogin, 10) === 0) {
|
||||||
return next(new Error('[[error:local-login-disabled]]'));
|
return next(new Error('[[error:local-login-disabled]]'));
|
||||||
}
|
}
|
||||||
if (!userData || !userData.password) {
|
|
||||||
return next(new Error('[[error:invalid-user-data]]'));
|
|
||||||
}
|
|
||||||
if (result.banned) {
|
if (result.banned) {
|
||||||
// Retrieve ban reason and show error
|
// Retrieve ban reason and show error
|
||||||
return user.getLatestBanInfo(uid, function (err, banInfo) {
|
return user.getLatestBanInfo(uid, function (err, banInfo) {
|
||||||
@@ -404,11 +397,14 @@ authenticationController.localLogin = function (req, username, password, next) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.auth.logAttempt(uid, req.ip, next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
Password.compare(password, userData.password, next);
|
Password.compare(password, userData.password, next);
|
||||||
},
|
},
|
||||||
function (passwordMatch, next) {
|
function (passwordMatch, next) {
|
||||||
if (!passwordMatch) {
|
if (!passwordMatch) {
|
||||||
return next(new Error('[[error:invalid-password]]'));
|
return next(new Error('[[error:invalid-login-credentials]]'));
|
||||||
}
|
}
|
||||||
user.auth.clearLoginAttempts(uid);
|
user.auth.clearLoginAttempts(uid);
|
||||||
next(null, userData, '[[success:authentication-successful]]');
|
next(null, userData, '[[success:authentication-successful]]');
|
||||||
@@ -441,6 +437,3 @@ authenticationController.logout = function (req, res, next) {
|
|||||||
res.status(200).send('');
|
res.status(200).send('');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = authenticationController;
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ module.exports = function (User) {
|
|||||||
User.auth = {};
|
User.auth = {};
|
||||||
|
|
||||||
User.auth.logAttempt = function (uid, ip, callback) {
|
User.auth.logAttempt = function (uid, ip, callback) {
|
||||||
|
if (!parseInt(uid, 10)) {
|
||||||
|
return setImmediate(callback);
|
||||||
|
}
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
db.exists('lockout:' + uid, next);
|
db.exists('lockout:' + uid, next);
|
||||||
|
|||||||
Reference in New Issue
Block a user