limits

package
v1.2.2-0...-4b8647b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limits

type Limits struct {
	// contains filtered or unexported fields
}

func NewLimits

func NewLimits(maxAttempts int, retryAfter time.Duration, incrementFactor int, maxTime time.Duration) *Limits

func (*Limits) CleanRateLimit

func (l *Limits) CleanRateLimit(username, categoryID string, provider string)

CleanRateLimit resets the rate limit count for a user

func (*Limits) IsRateLimited

func (l *Limits) IsRateLimited(username, categoryID string, provider string) error

IsRateLimited returns an error of type ErrRateLimited if the user is currently rate limited

func (*Limits) RecordFailedAttempt

func (l *Limits) RecordFailedAttempt(username, categoryID string, provider string) error

ReordFailedAttempt increases by 1 the failed attempts. If there's an active rate limit, it returns an ErrRateLimited error

type RateLimitError

type RateLimitError struct {
	RetryAfter time.Time
	// contains filtered or unexported fields
}

RateLimitError is an error that gets returned when the user has failed the login too much times

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL