Logging around accoung lock/unlocking
This commit is contained in:
parent
f0e7b46a2f
commit
a4823c0c4a
|
@ -152,6 +152,7 @@ module.exports = class User {
|
|||
if(!_.has(tempUser.properties, UserProps.AccountLockedPrevStatus)) {
|
||||
props[UserProps.AccountLockedPrevStatus] = tempUser.getProperty(UserProps.AccountStatus);
|
||||
}
|
||||
Log.info( { userId, failedAttempts }, '(Re)setting account to locked due to failed logins');
|
||||
return tempUser.persistProperties(props, callback);
|
||||
}
|
||||
|
||||
|
@ -243,6 +244,10 @@ module.exports = class User {
|
|||
const minutesSinceLocked = moment().diff(lockedTs, 'minutes');
|
||||
if(minutesSinceLocked >= autoUnlockMinutes) {
|
||||
// allow the login - we will clear any lock there
|
||||
Log.info(
|
||||
{ username, userId : tempAuthInfo.userId, lockedAt : lockedTs.format() },
|
||||
'Locked account will now be unlocked due to auto-unlock minutes policy'
|
||||
);
|
||||
return callback(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,14 +24,13 @@ function userLogin(client, username, password, cb) {
|
|||
const config = Config();
|
||||
|
||||
if(err) {
|
||||
client.log.info( { username : username, error : err.message }, 'Failed login attempt');
|
||||
|
||||
client.user.sessionFailedLoginAttempts = _.get(client.user, 'sessionFailedLoginAttempts', 0) + 1;
|
||||
const disconnect = config.users.failedLogin.disconnect;
|
||||
if(disconnect > 0 && client.user.sessionFailedLoginAttempts >= disconnect) {
|
||||
return cb(Errors.BadLogin('To many failed login attempts', ErrorReasons.TooMany));
|
||||
err = Errors.BadLogin('To many failed login attempts', ErrorReasons.TooMany);
|
||||
}
|
||||
|
||||
client.log.info( { username : username, error : err.message }, 'Failed login attempt');
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
|
|
|
@ -288,6 +288,10 @@ class WebPasswordReset {
|
|||
user.removeProperties([ UserProps.EmailPwResetToken, UserProps.EmailPwResetTokenTs ]);
|
||||
|
||||
if(true === _.get(config, 'users.unlockAtEmailPwReset')) {
|
||||
Log.info(
|
||||
{ username : user.username, userId : user.userId },
|
||||
'Remove any lock on account due to password reset policy'
|
||||
);
|
||||
user.unlockAccount( () => { /* dummy */ } );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue