class PasswordBroker implements PasswordBroker

Constants

SENDING_BROKER_CONTEXT_KEY

The coroutine context key holding the broker name currently sending a reset link.

Properties

protected Timebox $timebox

The timebox instance.

Methods

__construct(TokenRepositoryInterface $tokens, UserProvider $users, string $name, Dispatcher|null $events = null, Timebox|null $timebox = null, int $timeboxDuration = 200000)

Create a new password broker instance.

string
sendResetLink(array $credentials, Closure|null $callback = null)

Send a password reset link to a user.

mixed
reset(array $credentials, Closure $callback)

Reset the password for the given token.

validateReset(array $credentials)

Validate a password reset for the given credentials.

getUser(array $credentials)

Get the user for the given credentials.

string
createToken(CanResetPassword $user)

Create a new password reset token for the given user.

void
deleteToken(CanResetPassword $user)

Delete password reset tokens of the given user.

bool
tokenExists(CanResetPassword $user, string $token)

Validate the given password reset token.

getRepository()

Get the password reset token repository implementation.

getTimebox()

Get the timebox instance used by the broker.

void
setDispatcher(Dispatcher $events)

Set the event dispatcher instance.

Details

at line 37
__construct(TokenRepositoryInterface $tokens, UserProvider $users, string $name, Dispatcher|null $events = null, Timebox|null $timebox = null, int $timeboxDuration = 200000)

Create a new password broker instance.

Parameters

TokenRepositoryInterface $tokens
UserProvider $users
string $name
Dispatcher|null $events
Timebox|null $timebox
int $timeboxDuration

the number of microseconds that the timebox should wait for

Send a password reset link to a user.

Parameters

array $credentials
Closure|null $callback

Return Value

string

at line 100
mixed reset(array $credentials, Closure $callback)

Reset the password for the given token.

Parameters

array $credentials
Closure $callback

Return Value

mixed

at line 130
protected CanResetPassword|string validateReset(array $credentials)

Validate a password reset for the given credentials.

Parameters

array $credentials

Return Value

CanResetPassword|string

at line 148
CanResetPassword|null getUser(array $credentials)

Get the user for the given credentials.

Parameters

array $credentials

Return Value

CanResetPassword|null

Exceptions

UnexpectedValueException

at line 164
string createToken(CanResetPassword $user)

Create a new password reset token for the given user.

Parameters

CanResetPassword $user

Return Value

string

at line 172
void deleteToken(CanResetPassword $user)

Delete password reset tokens of the given user.

Parameters

CanResetPassword $user

Return Value

void

at line 180
bool tokenExists(CanResetPassword $user, string $token)

Validate the given password reset token.

Parameters

CanResetPassword $user
string $token

Return Value

bool

at line 188
TokenRepositoryInterface getRepository()

Get the password reset token repository implementation.

at line 196
Timebox getTimebox()

Get the timebox instance used by the broker.

Return Value

Timebox

at line 207
void setDispatcher(Dispatcher $events)

Set the event dispatcher instance.

The dispatcher is stored on the worker-lifetime broker and affects every subsequent password reset-link event.

Parameters

Dispatcher $events

Return Value

void