From e0c8989e8beceb10d01ffbb10dfbbcc5252fc49f Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 11 Dec 2014 10:17:04 -0500 Subject: [PATCH] closes #2519 --- src/events.js | 7 +++++++ src/user/auth.js | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/events.js b/src/events.js index d24c6aec4f..bab042f28e 100644 --- a/src/events.js +++ b/src/events.js @@ -78,6 +78,13 @@ var fs = require('fs'), events.logWithUser(uid, 'restored topic (tid ' + tid + ')'); }; + events.logAccountLock = function(uid, until) { + var date = new Date(); + date.setTime(date.getTime() + until); + + events.logWithUser(uid, 'locked out until ' + date.toString()); + }; + events.logWithUser = function(uid, string) { user.getUserField(uid, 'username', function(err, username) { if(err) { diff --git a/src/user/auth.js b/src/user/auth.js index 19263c7cdb..b275882cf1 100644 --- a/src/user/auth.js +++ b/src/user/auth.js @@ -2,7 +2,8 @@ var async = require('async'), db = require('../database'), - meta = require('../meta'); + meta = require('../meta'), + events = require('../events'); module.exports = function(User) { User.auth = {}; @@ -28,8 +29,12 @@ module.exports = function(User) { if (err) { return callback(err); } + var duration = 1000 * 60 * (meta.config.lockoutDuration || 60); + db.delete('loginAttempts:' + uid); - db.pexpire('lockout:' + uid, 1000 * 60 * (meta.config.lockoutDuration || 60)); + db.pexpire('lockout:' + uid, duration); + + events.logAccountLock(uid, duration); callback(new Error('account-locked')); }); } else {