mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Merge pull request #1850 from hswolff/fix-throttle-behavior
Remove successful login connections from the auth throttle list
This commit is contained in:
commit
b9a221a2be
1 changed files with 8 additions and 3 deletions
|
@ -72,16 +72,17 @@ adminControllers = {
|
|||
},
|
||||
'auth': function (req, res) {
|
||||
var currentTime = process.hrtime()[0],
|
||||
remoteAddress = req.connection.remoteAddress,
|
||||
denied = '';
|
||||
loginSecurity = _.filter(loginSecurity, function (ipTime) {
|
||||
return (ipTime.time + 2 > currentTime);
|
||||
});
|
||||
denied = _.find(loginSecurity, function (ipTime) {
|
||||
return (ipTime.ip === req.connection.remoteAddress);
|
||||
return (ipTime.ip === remoteAddress);
|
||||
});
|
||||
|
||||
if (!denied) {
|
||||
loginSecurity.push({ip: req.connection.remoteAddress, time: process.hrtime()[0]});
|
||||
loginSecurity.push({ip: remoteAddress, time: currentTime});
|
||||
api.users.check({email: req.body.email, pw: req.body.password}).then(function (user) {
|
||||
req.session.regenerate(function (err) {
|
||||
if (!err) {
|
||||
|
@ -90,7 +91,11 @@ adminControllers = {
|
|||
if (req.body.redirect) {
|
||||
redirect += decodeURIComponent(req.body.redirect);
|
||||
}
|
||||
|
||||
// If this IP address successfully logins we
|
||||
// can remove it from the array of failed login attempts.
|
||||
loginSecurity = _.reject(loginSecurity, function (ipTime) {
|
||||
return ipTime.ip === remoteAddress;
|
||||
});
|
||||
res.json(200, {redirect: redirect});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue