@@ -100,8 +100,11 @@ manage user authentication, as shown in the following code:
100
100
Customize User Authentication
101
101
-----------------------------
102
102
103
- In this section, you can learn how to use the following features to
104
- customize your MongoDB user authentication process:
103
+ You can customize your authentication files to align with your application's
104
+ needs and enable additional authentication features.
105
+
106
+ This section describes how to use the following features to customize the MongoDB user
107
+ authentication process:
105
108
106
109
- :ref:`laravel-user-auth-sanctum`
107
110
- :ref:`laravel-user-auth-reminders`
@@ -111,45 +114,40 @@ customize your MongoDB user authentication process:
111
114
Laravel Sanctum
112
115
~~~~~~~~~~~~~~~
113
116
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.
117
+ Laravel Sanctum is an authentication package that can manage API requests and
118
+ single-page application authentication . To manage API requests , Sanctum issues
119
+ API tokens that are stored in a database table and authenticates incoming HTTP
120
+ requests by using the ``Authorization`` header. To authenticate single-page applications,
121
+ Sanctum uses Laravel's cookie-based authentication services.
119
122
120
- Run the following commands from your project root to install Laravel Sanctum,
121
- then publish and run its migration files:
123
+ You can install Laravel Sanctum to manage your application's authentication
124
+ process. Run the following commands from your project root to install Laravel
125
+ Sanctum and publish its migration file:
122
126
123
127
.. code-block:: bash
124
128
125
129
composer require laravel/sanctum
126
130
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
127
- php artisan migrate
128
-
129
- .. tip::
130
-
131
- To learn more about installing and configuring Laravel Sanctum, see the
132
- `Installation <https://laravel.com/docs/{+laravel-docs-version+}/sanctum#installation>`__
133
- section of the Laravel Sanctum guide.
134
-
135
- To use Laravel Sanctum with {+odm-short+}, you must modify the ``PersonalAccessToken``
136
- model provided by Sanctum.
137
-
138
- Example
139
- ```````
140
131
141
- The following code extends the ``PersonalAccessToken`` model provided by Sanctum
132
+ Next, modify the ``PersonalAccessToken`` model provided by Laravel Sanctum to use
133
+ Sanctum with {+odm-short+}. The following code extends the ``PersonalAccessToken`` model
142
134
to enable MongoDB:
143
135
144
136
.. literalinclude:: /includes/auth/PersonalAccessToken.php
145
137
:language: php
146
138
:dedent:
147
139
148
- After modifying the ``PersonalAccessToken`` model, instruct Sanctum to use the custom
149
- model by calling the ``usePersonalAccessTokenModel()`` method in one of your application's
150
- service providers. To learn more, see the `Overriding Default Models
140
+ Then, run the following command to modify the database schema to handle API tokens:
141
+
142
+ .. code-block:: bash
143
+
144
+ php artisan migrate
145
+
146
+ You can now instruct Sanctum to use the custom ``PersonalAccessToken`` model by calling
147
+ the ``usePersonalAccessTokenModel()`` method in one of your application's
148
+ service providers. To learn more, see `Overriding Default Models
151
149
<https://laravel.com/docs/{+laravel-docs-version+}/sanctum#overriding-default-models>`__
152
- section of the Laravel Sanctum guide.
150
+ in the Laravel Sanctum guide.
153
151
154
152
.. _laravel-user-auth-reminders:
155
153
0 commit comments