mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-14 11:32:52 +01:00
closes #2519
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user