v1.18.x
psychobunny 10 years ago
parent 94efa6dd87
commit e0c8989e8b

@ -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) {

@ -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 {

Loading…
Cancel
Save