fix panic when unlocking unlocked user (#23611)

This commit is contained in:
davidadeleon 2023-10-11 12:59:48 -04:00 committed by GitHub
parent 813c786032
commit 2f8e59c856
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,14 +51,16 @@ func unlockUser(ctx context.Context, core *Core, mountAccessor string, aliasName
return err
}
// Check if we have no more locked users and cancel any running lockout logger
core.userFailedLoginInfoLock.RLock()
numLockedUsers := len(core.userFailedLoginInfo)
core.userFailedLoginInfoLock.RUnlock()
if core.lockoutLoggerCancel != nil {
// Check if we have no more locked users and cancel any running lockout logger
core.userFailedLoginInfoLock.RLock()
numLockedUsers := len(core.userFailedLoginInfo)
core.userFailedLoginInfoLock.RUnlock()
if numLockedUsers == 0 {
core.Logger().Info("user lockout(s) cleared")
core.lockoutLoggerCancel()
if numLockedUsers == 0 {
core.Logger().Info("user lockout(s) cleared")
core.lockoutLoggerCancel()
}
}
return nil