mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 16:22:04 +00:00
fix: expire abandoned auth attempts
This commit is contained in:
@@ -130,6 +130,26 @@ func (c *AuthCoordinator) Get(attemptID string) (AuthAttempt, error) {
|
||||
return attempt, nil
|
||||
}
|
||||
|
||||
// Expire closes abandoned pending attempts. The caller should run this from
|
||||
// the auth maintenance loop; accepted and already terminal attempts are left
|
||||
// unchanged so audit/reconciliation can still inspect their outcome.
|
||||
func (c *AuthCoordinator) Expire(now time.Time) []AuthAttempt {
|
||||
if c == nil || now.IsZero() {
|
||||
return nil
|
||||
}
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
var expired []AuthAttempt
|
||||
for id, attempt := range c.attempts {
|
||||
if attempt.State == AuthPending && !now.Before(attempt.ExpiresAt) {
|
||||
attempt.State = AuthRejected
|
||||
c.attempts[id] = attempt
|
||||
expired = append(expired, attempt)
|
||||
}
|
||||
}
|
||||
return expired
|
||||
}
|
||||
|
||||
var (
|
||||
ErrTicketRejected = fmt.Errorf("steam ticket rejected")
|
||||
ErrSessionRejected = fmt.Errorf("session rejected")
|
||||
|
||||
Reference in New Issue
Block a user