UsernameRecoveryService
class UsernameRecoveryService (View source)
Username recovery by email: rate-limits requests and mails the usernames registered to an address.
Methods
__construct(UsernameRecoveryRepositoryInterface $recoveryRepository, MailService $mailService, ConfigurationInterface $config, ClientContext $client, LoggerInterface $logger, UserLookupInterface $users, UrlService $urlService)
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(UsernameRecoveryRepositoryInterface $recoveryRepository, MailService $mailService, ConfigurationInterface $config, ClientContext $client, LoggerInterface $logger, UserLookupInterface $users, UrlService $urlService)
No description
bool
isEnabled()
Check if username recovery is enabled
bool
createRecoveryRequest(string $email)
Create a username recovery request
This method handles the entire username recovery flow:
- Validates rate limits
- Finds all accounts associated with the email
- Sends recovery email with username information
- Records the request for rate limiting
Security: Always returns true to prevent email enumeration attacks
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