final class DbUsernameRecoveryRepository implements UsernameRecoveryRepositoryInterface (View source)

SQL persistence for username recovery attempts and their rate-limit counters in username_recovery_requests.

Methods

__construct(PDO $db, ConfigurationInterface $config)

No description

bool
create(array $data)

Create a new username recovery request record

int
countRecentAttempts(string $email, int $seconds)

Count recent recovery attempts for a specific email address

int
countRecentAttemptsByIp(string $ip, int $seconds)

Count recent recovery attempts by IP address

int
deleteOlderThan(int $days = 30)

Delete old recovery request records

Details

__construct(PDO $db, ConfigurationInterface $config)

No description

Parameters

PDO $db
ConfigurationInterface $config

bool create(array $data)

Create a new username recovery request record

Parameters

array $data

Request data containing email and ip_address

Return Value

bool

True if the record was created successfully

int countRecentAttempts(string $email, int $seconds)

Count recent recovery attempts for a specific email address

Parameters

string $email
int $seconds

Time window in seconds to check within

Return Value

int

int countRecentAttemptsByIp(string $ip, int $seconds)

Count recent recovery attempts by IP address

Parameters

string $ip
int $seconds

Time window in seconds to check within

Return Value

int

int deleteOlderThan(int $days = 30)

Delete old recovery request records

Cleanup strategy:

  • Delete records older than the specified number of days
  • Default: 30 days for audit trail purposes

This method can be called periodically for maintenance.

Parameters

int $days

Return Value

int

Number of deleted records