diff --git a/vault/logical_system_user_lockout.go b/vault/logical_system_user_lockout.go index de2f6534649a..3e447b58ab3a 100644 --- a/vault/logical_system_user_lockout.go +++ b/vault/logical_system_user_lockout.go @@ -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 numLockedUsers == 0 { - core.Logger().Info("user lockout(s) cleared") - core.lockoutLoggerCancel() + 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() + } } return nil