MCPcopy Index your code
hub / github.com/tinyauthapp/tinyauth / IsAccountLocked

Method IsAccountLocked

internal/service/auth_service.go:227–251  ·  view source on GitHub ↗
(identifier string)

Source from the content-addressed store, hash-verified

225}
226
227func (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
253func (auth *AuthService) RecordLoginAttempt(identifier string, success bool) {
254 if auth.config.LoginMaxRetries <= 0 || auth.config.LoginTimeout <= 0 {

Callers 3

MiddlewareMethod · 0.80
loginHandlerMethod · 0.80
totpHandlerMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected