(identifier string)
| 225 | } |
| 226 | |
| 227 | func (auth *AuthService) IsAccountLocked(identifier string) (bool, int) { |
| 228 | auth.loginMutex.RLock() |
| 229 | defer auth.loginMutex.RUnlock() |
| 230 | |
| 231 | if auth.lockdown != nil && auth.lockdown.Active { |
| 232 | remaining := int(time.Until(auth.lockdown.ActiveUntil).Seconds()) |
| 233 | return true, remaining |
| 234 | } |
| 235 | |
| 236 | if auth.config.LoginMaxRetries <= 0 || auth.config.LoginTimeout <= 0 { |
| 237 | return false, 0 |
| 238 | } |
| 239 | |
| 240 | attempt, exists := auth.loginAttempts[identifier] |
| 241 | if !exists { |
| 242 | return false, 0 |
| 243 | } |
| 244 | |
| 245 | if attempt.LockedUntil.After(time.Now()) { |
| 246 | remaining := int(time.Until(attempt.LockedUntil).Seconds()) |
| 247 | return true, remaining |
| 248 | } |
| 249 | |
| 250 | return false, 0 |
| 251 | } |
| 252 | |
| 253 | func (auth *AuthService) RecordLoginAttempt(identifier string, success bool) { |
| 254 | if auth.config.LoginMaxRetries <= 0 || auth.config.LoginTimeout <= 0 { |
no outgoing calls
no test coverage detected