class UsernameRecoveryService (View source)

Methods

__construct(DbUsernameRecoveryRepository $recoveryRepository, MailService $mailService, ConfigurationInterface $config, IpAddressRetriever $ipRetriever, LoggerInterface $logger, PDO $db)

No description

bool
isEnabled()

Check if username recovery is enabled

bool
createRecoveryRequest(string $email)

Create a username recovery request

void
cleanupOldRequests(int $days = 30)

Clean up old recovery request records

Details

__construct(DbUsernameRecoveryRepository $recoveryRepository, MailService $mailService, ConfigurationInterface $config, IpAddressRetriever $ipRetriever, LoggerInterface $logger, PDO $db)

No description

Parameters

DbUsernameRecoveryRepository $recoveryRepository
MailService $mailService
ConfigurationInterface $config
IpAddressRetriever $ipRetriever
LoggerInterface $logger
PDO $db

bool isEnabled()

Check if username recovery is enabled

Return Value

bool

True if username recovery is enabled

bool createRecoveryRequest(string $email)

Create a username recovery request

This method handles the entire username recovery flow:

  1. Validates rate limits
  2. Finds all accounts associated with the email
  3. Sends recovery email with username information
  4. Records the request for rate limiting

Security: Always returns true to prevent email enumeration attacks

Parameters

string $email

Email address to recover username for

Return Value

bool

Always returns true for security (don't reveal if email exists)

void cleanupOldRequests(int $days = 30)

Clean up old recovery request records

This method can be called periodically to clean up old records. Default: Delete records older than 30 days

Parameters

int $days

Number of days to keep records (default: 30)

Return Value

void