class PasswordResetService (View source)

Methods

__construct(DbPasswordResetTokenRepository $tokenRepository, UserRepository $userRepository, MailService $mailService, ConfigurationInterface $config, UserAuthenticationService $authService, IpAddressRetriever $ipRetriever, LoggerInterface $logger)

No description

bool
isEnabled()

Check if password reset is enabled

array
canUserResetPassword(string $email)

Check if a user's authentication method allows password reset

bool
createResetRequest(string $email)

Create a password reset request

array|null
validateToken(string $token)

Validate a password reset token

bool
resetPassword(string $token, string $newPassword)

Reset password using a valid token

void
cleanupExpiredTokens()

Clean up expired tokens

Details

__construct(DbPasswordResetTokenRepository $tokenRepository, UserRepository $userRepository, MailService $mailService, ConfigurationInterface $config, UserAuthenticationService $authService, IpAddressRetriever $ipRetriever, LoggerInterface $logger)

No description

Parameters

DbPasswordResetTokenRepository $tokenRepository
UserRepository $userRepository
MailService $mailService
ConfigurationInterface $config
UserAuthenticationService $authService
IpAddressRetriever $ipRetriever
LoggerInterface $logger

bool isEnabled()

Check if password reset is enabled

Return Value

bool

array canUserResetPassword(string $email)

Check if a user's authentication method allows password reset

Parameters

string $email

User email address

Return Value

array

Result array with 'allowed' boolean and optional 'auth_method' for blocked users

bool createResetRequest(string $email)

Create a password reset request

Parameters

string $email

Return Value

bool

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

array|null validateToken(string $token)

Validate a password reset token

Parameters

string $token

Return Value

array|null

Returns user data if valid, null otherwise

bool resetPassword(string $token, string $newPassword)

Reset password using a valid token

Parameters

string $token
string $newPassword

Return Value

bool

void cleanupExpiredTokens()

Clean up expired tokens

This method can be called from anywhere to clean up expired tokens. It's automatically called during:

  • Creating new password reset requests
  • Validating tokens
  • Successful password resets

Return Value

void