PasswordBroker.php
TLDR
This file defines the PasswordBroker
interface, which provides methods for sending a password reset link to a user and resetting the password using a token.
Methods
sendResetLink
This method sends a password reset link to a user.
- Parameters:
-
array $credentials
: The user's credentials (e.g., email). -
\Closure|null $callback
: An optional callback to be executed after the reset link is sent.
-
- Returns:
string
- Example usage:
$credentials = [ 'email' => 'user@example.com', ]; $broker->sendResetLink($credentials);
reset
This method resets the password for the given token.
- Parameters:
-
array $credentials
: The user's credentials (e.g., email, new password). -
\Closure $callback
: A callback to be executed after the password is reset.
-
- Returns:
mixed
- Example usage:
$credentials = [ 'email' => 'user@example.com', 'password' => 'new_password', 'token' => 'reset_token', ]; $broker->reset($credentials, function ($user, $password) { // Perform necessary actions after password reset });
<?php
namespace Illuminate\Contracts\Auth;
use Closure;
interface PasswordBroker
{
/**
* Constant representing a successfully sent reminder.
*
* @var string
*/
const RESET_LINK_SENT = 'passwords.sent';
/**
* Constant representing a successfully reset password.
*
* @var string
*/
const PASSWORD_RESET = 'passwords.reset';
/**
* Constant representing the user not found response.
*
* @var string
*/
const INVALID_USER = 'passwords.user';
/**
* Constant representing an invalid token.
*
* @var string
*/
const INVALID_TOKEN = 'passwords.token';
/**
* Constant representing a throttled reset attempt.
*
* @var string
*/
const RESET_THROTTLED = 'passwords.throttled';
/**
* Send a password reset link to a user.
*
* @param array $credentials
* @param \Closure|null $callback
* @return string
*/
public function sendResetLink(array $credentials, Closure $callback = null);
/**
* Reset the password for the given token.
*
* @param array $credentials
* @param \Closure $callback
* @return mixed
*/
public function reset(array $credentials, Closure $callback);
}