You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[12.x] document the password reset cache driver (#10534)
* document the password reset `cache` driver
document laravel/framework#53428
I modeled the wording and organization after the `session.md` docs for hopefully a little consistency.
* add note about how we key the entries
* formatting
---------
Co-authored-by: Taylor Otwell <[email protected]>
-[Requesting the Password Reset Link](#requesting-the-password-reset-link)
@@ -18,18 +19,54 @@ Most web applications provide a way for users to reset their forgotten passwords
18
19
> [!NOTE]
19
20
> Want to get started fast? Install a Laravel [application starter kit](/docs/{{version}}/starter-kits) in a fresh Laravel application. Laravel's starter kits will take care of scaffolding your entire authentication system, including resetting forgotten passwords.
20
21
22
+
<aname="configuration"></a>
23
+
### Configuration
24
+
25
+
Your application's password reset configuration file is stored at `config/auth.php`. Be sure to review the options available to you in this file. By default, Laravel is configured to use the `database` password reset driver.
26
+
27
+
The password reset `driver` configuration option defines where password reset data will be stored. Laravel includes two drivers:
28
+
29
+
<divclass="content-list"markdown="1">
30
+
31
+
-`database` - password reset data is stored in a relational database.
32
+
-`cache` - password reset data is stored in one of your cache based stores.
33
+
34
+
</div>
35
+
36
+
<aname="driver-prerequisites"></a>
37
+
### Driver Prerequisites
38
+
39
+
<aname="database"></a>
40
+
#### Database
41
+
42
+
When using the default `database` driver, a table must be created to store your application's password reset tokens. Typically, this is included in Laravel's default `0001_01_01_000000_create_users_table.php` database migration.
43
+
44
+
<aname="cache"></a>
45
+
#### Cache
46
+
47
+
There is also a cache driver available for handling password resets, which does not require a dedicated database table. Entries are keyed by the user's email address, so ensure you are not using email addresses as a cache key elsewhere in your application:
48
+
49
+
```php
50
+
'passwords' => [
51
+
'users' => [
52
+
'driver' => 'cache',
53
+
'provider' => 'users',
54
+
'store' => 'passwords', // Optional...
55
+
'expire' => 60,
56
+
'throttle' => 60,
57
+
],
58
+
],
59
+
```
60
+
61
+
To prevent a call to `artisan cache:clear` from flushing your password reset data, you can optionally specify a separate cache store with the `store` configuration key. The value should correspond to a store configured in your `config/cache.php` configuration value.
62
+
21
63
<aname="model-preparation"></a>
22
64
### Model Preparation
23
65
24
66
Before using the password reset features of Laravel, your application's `App\Models\User` model must use the `Illuminate\Notifications\Notifiable` trait. Typically, this trait is already included on the default `App\Models\User` model that is created with new Laravel applications.
25
67
26
68
Next, verify that your `App\Models\User` model implements the `Illuminate\Contracts\Auth\CanResetPassword` contract. The `App\Models\User` model included with the framework already implements this interface, and uses the `Illuminate\Auth\Passwords\CanResetPassword` trait to include the methods needed to implement the interface.
27
69
28
-
<aname="database-preparation"></a>
29
-
### Database Preparation
30
-
31
-
A table must be created to store your application's password reset tokens. Typically, this is included in Laravel's default `0001_01_01_000000_create_users_table.php` database migration.
32
-
33
70
<aname="configuring-trusted-hosts"></a>
34
71
### Configuring Trusted Hosts
35
72
@@ -160,7 +197,7 @@ Before moving on, you may be wondering how Laravel knows how to retrieve the use
160
197
<aname="deleting-expired-tokens"></a>
161
198
## Deleting Expired Tokens
162
199
163
-
Password reset tokens that have expired will still be present within your database. However, you may easily delete these records using the `auth:clear-resets` Artisan command:
200
+
If you are using the `database` driver, password reset tokens that have expired will still be present within your database. However, you may easily delete these records using the `auth:clear-resets` Artisan command:
0 commit comments