@@ -97,8 +97,58 @@ manage user authentication, as shown in the following code:
97
97
:language: php
98
98
:dedent:
99
99
100
- Enable Password Reminders
101
- -------------------------
100
+ Customize User Authentication
101
+ -----------------------------
102
+
103
+ In this section, you can learn how to use the following features to
104
+ customize your MongoDB user authentication process:
105
+
106
+ - :ref:`laravel-user-auth-sanctum`
107
+ - :ref:`laravel-user-auth-reminders`
108
+
109
+ .. _laravel-user-auth-sanctum:
110
+
111
+ Laravel Sanctum
112
+ ~~~~~~~~~~~~~~~
113
+
114
+ You can install the Laravel Sanctum package to provide API tokens to users
115
+ and authenticate single-page applications. To manage API tokens, Sanctum stores
116
+ each token in a database table and authenticates incoming HTTP requests through
117
+ the ``Authorization`` header. To authenticate single-page applications, Sanctum
118
+ uses Laravel's cookie-based authentication services.
119
+
120
+ Run the following commands from your project root to install Laravel Sanctum,
121
+ then publish and run its migration files:
122
+
123
+ .. code-block:: php
124
+
125
+ composer require laravel/sanctum
126
+ php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
127
+ php artisan migrate
128
+
129
+ To use Laravel Sanctum with {+odm-short+}, you must modify the ``PersonalAccessToken``
130
+ model provided by Sanctum.
131
+
132
+ Example
133
+ ```````
134
+
135
+ The following code extends the ``PersonalAccessToken`` model provided by Sanctum
136
+ to enable MongoDB:
137
+
138
+ .. literalinclude:: /includes/auth/PersonalAccessToken.php
139
+ :language: php
140
+ :dedent:
141
+
142
+ After modifying the ``PersonalAccessToken`` model, instruct Sanctum to use the custom
143
+ model by calling the ``usePersonalAccessTokenModel()`` method in one of your application's
144
+ service providers. To learn more, see the `Overriding Default Models
145
+ <https://laravel.com/docs/{+laravel-docs-version+}/sanctum#overriding-default-models>`__
146
+ section of the Sanctum documentation.
147
+
148
+ .. _laravel-user-auth-reminders:
149
+
150
+ Password Reminders
151
+ ~~~~~~~~~~~~~~~~~~
102
152
103
153
To add support for MongoDB-based password reminders, register the following service
104
154
provider in your application:
@@ -111,7 +161,7 @@ This service provider modifies the internal ``DatabaseReminderRepository``
111
161
to enable password reminders.
112
162
113
163
Example
114
- ~~~~~~~
164
+ ```````
115
165
116
166
The following code updates the ``providers.php`` file in the ``bootstrap`` directory
117
167
of a Laravel application to register the ``PasswordResetServiceProvider`` provider:
0 commit comments