Skip to content

Commit 0559dfc

Browse files
committed
Merge branch '8.x'
2 parents 01d1a24 + f6e16a9 commit 0559dfc

File tree

10 files changed

+212
-66
lines changed

10 files changed

+212
-66
lines changed

authentication.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ Also, you should verify that your `users` (or equivalent) table contains a nulla
5151
<a name="authentication-quickstart"></a>
5252
## Authentication Quickstart
5353

54+
> {note} This portion of the documentation discusses authenticating users via the [Laravel Jetstream](https://jetstream.laravel.com) package, which includes UI scaffolding to help you get started quickly. If you would like to integrate with Laravel's authentication systems directly, check out the documentation on [manually authenticating users](#authenticating-users).
55+
5456
<a name="included-routing"></a>
5557
### Routing
5658

57-
Laravel's `laravel/jetstream` package provides a quick way to scaffold all of the routes and views you need for authentication using a few simple commands:
59+
Laravel's `laravel/jetstream` package provides a quick way to scaffold all of the routes, views, and other backend logic needed for authentication using a few simple commands:
5860

5961
composer require laravel/jetstream
6062

@@ -66,25 +68,25 @@ Laravel's `laravel/jetstream` package provides a quick way to scaffold all of th
6668

6769
This command should be used on fresh applications and will install a layout view, registration and login views, as well as routes for all authentication end-points. A `/dashboard` route will also be generated to handle post-login requests to your application's dashboard.
6870

69-
To learn more about Jetstream, please visit the official [Jetstream documentation](https://jetstream.laravel.com).
70-
7171
#### Creating Applications Including Authentication
7272

7373
If you are starting a brand new application and would like to include the authentication scaffolding, you may use the `--jet` directive when creating your application via the Laravel Installer. This command will create a new application with all of the authentication scaffolding compiled and installed:
7474

7575
laravel new kitetail --jet
7676

77+
> {tip} To learn more about Jetstream, please visit the official [Jetstream documentation](https://jetstream.laravel.com).
78+
7779
<a name="included-views"></a>
7880
### Views
7981

8082
As mentioned in the previous section, the `laravel/jetstream` package's `php artisan jetstream:install` command will create all of the views you need for authentication and place them in the `resources/views/auth` directory.
8183

82-
Jetstream will also create a `resources/views/layouts` directory containing a base layout for your application. All of these views use the Tailwind CSS framework, but you are free to customize them however you wish.
84+
Jetstream will also create a `resources/views/layouts` directory containing a base layout for your application. All of these views use the [Tailwind CSS](https://tailwindcss.com) framework, but you are free to customize them however you wish.
8385

8486
<a name="included-authenticating"></a>
8587
### Authenticating
8688

87-
Now that you have routes and views setup for the included authentication controllers, you are ready to register and authenticate new users for your application! You may access your application in a browser since Jetstream's authentication controllers already contain the logic to authenticate existing users and store new users in the database.
89+
Now that your application has been scaffolded for authentication, you are ready to register and authenticate! You may simply access your application in a browser since Jetstream's authentication controllers already contain the logic to authenticate existing users and store new users in the database.
8890

8991
#### Path Customization
9092

@@ -115,10 +117,10 @@ Alternatively, once a user is authenticated, you may access the authenticated us
115117

116118
use Illuminate\Http\Request;
117119

118-
class ProfileController extends Controller
120+
class FlightController extends Controller
119121
{
120122
/**
121-
* Update the user's profile.
123+
* Get a list of all available flights.
122124
*
123125
* @param Request $request
124126
* @return Response
@@ -144,19 +146,12 @@ To determine if the user is already logged into your application, you may use th
144146
<a name="protecting-routes"></a>
145147
### Protecting Routes
146148

147-
[Route middleware](/docs/{{version}}/middleware) can be used to only allow authenticated users to access a given route. Laravel ships with an `auth` middleware, which is defined at `Illuminate\Auth\Middleware\Authenticate`. Since this middleware is already registered in your HTTP kernel, all you need to do is attach the middleware to a route definition:
149+
[Route middleware](/docs/{{version}}/middleware) can be used to only allow authenticated users to access a given route. Laravel ships with an `auth` middleware, which references the `Illuminate\Auth\Middleware\Authenticate` class. Since this middleware is already registered in your HTTP kernel, all you need to do is attach the middleware to a route definition:
148150

149-
Route::get('profile', function () {
151+
Route::get('flights', function () {
150152
// Only authenticated users may enter...
151153
})->middleware('auth');
152154

153-
If you are using [controllers](/docs/{{version}}/controllers), you may call the `middleware` method from the controller's constructor instead of attaching it in the route definition directly:
154-
155-
public function __construct()
156-
{
157-
$this->middleware('auth');
158-
}
159-
160155
#### Redirecting Unauthenticated Users
161156

162157
When the `auth` middleware detects an unauthorized user, it will redirect the user to the `login` [named route](/docs/{{version}}/routing#named-routes). You may modify this behavior by updating the `redirectTo` function in your `app/Http/Middleware/Authenticate.php` file:
@@ -176,20 +171,21 @@ When the `auth` middleware detects an unauthorized user, it will redirect the us
176171

177172
When attaching the `auth` middleware to a route, you may also specify which guard should be used to authenticate the user. The guard specified should correspond to one of the keys in the `guards` array of your `auth.php` configuration file:
178173

179-
public function __construct()
180-
{
181-
$this->middleware('auth:api');
182-
}
174+
Route::get('flights', function () {
175+
// Only authenticated users may enter...
176+
})->middleware('auth:api');
183177

184178
<a name="login-throttling"></a>
185179
### Login Throttling
186180

187181
If you are using Laravel Jetstream, rate limiting will automatically be applied to login attempts. By default, the user will not be able to login for one minute if they fail to provide the correct credentials after several attempts. The throttling is unique to the user's username / e-mail address and their IP address.
188182

183+
> {tip} If you would like to rate limit your own routes, check out the [rate limiting documentation](/docs/{{version}}/routing#rate-limiting).
184+
189185
<a name="authenticating-users"></a>
190186
## Manually Authenticating Users
191187

192-
Note that you are not required to use the authentication controllers included with Laravel Jetstream. If you choose to not use this scaffolding, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!
188+
You are not required to use the authentication scaffolding included with Laravel Jetstream. If you choose to not use this scaffolding, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!
193189

194190
We will access Laravel's authentication services via the `Auth` [facade](/docs/{{version}}/facades), so we'll need to make sure to import the `Auth` facade at the top of the class. Next, let's check out the `attempt` method:
195191

@@ -272,7 +268,7 @@ If you are "remembering" users, you may use the `viaRemember` method to determin
272268

273269
#### Authenticate A User Instance
274270

275-
If you need to log an existing user instance into your application, you may call the `login` method with the user instance. The given object must be an implementation of the `Illuminate\Contracts\Auth\Authenticatable` [contract](/docs/{{version}}/contracts). The `App\Models\User` model included with Laravel already implements this interface:
271+
If you need to log an existing user instance into your application, you may call the `login` method with the user instance. The given object must be an implementation of the `Illuminate\Contracts\Auth\Authenticatable` [contract](/docs/{{version}}/contracts). The `App\Models\User` model included with Laravel already implements this interface. This method of authentication is useful when you already have a valid user instance, such as directly after a user registers with your application:
276272

277273
Auth::login($user);
278274

eloquent-mutators.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ As an example, we will define a custom cast class that casts multiple model valu
268268

269269
namespace App\Casts;
270270

271-
use App\Models\Address;
271+
use App\Models\Address as AddressModel;
272272
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
273273
use InvalidArgumentException;
274274

@@ -285,7 +285,7 @@ As an example, we will define a custom cast class that casts multiple model valu
285285
*/
286286
public function get($model, $key, $value, $attributes)
287287
{
288-
return new Address(
288+
return new AddressModel(
289289
$attributes['address_line_one'],
290290
$attributes['address_line_two']
291291
);
@@ -302,7 +302,7 @@ As an example, we will define a custom cast class that casts multiple model valu
302302
*/
303303
public function set($model, $key, $value, $attributes)
304304
{
305-
if (! $value instanceof Address) {
305+
if (! $value instanceof AddressModel) {
306306
throw new InvalidArgumentException('The given value is not an Address instance.');
307307
}
308308

hashing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<a name="introduction"></a>
88
## Introduction
99

10-
The Laravel `Hash` [facade](/docs/{{version}}/facades) provides secure Bcrypt and Argon2 hashing for storing user passwords. If you are using the built-in `LoginController` and `RegisterController` classes that are included with your Laravel application, they will use Bcrypt for registration and authentication by default.
10+
The Laravel `Hash` [facade](/docs/{{version}}/facades) provides secure Bcrypt and Argon2 hashing for storing user passwords. If you are using the [Laravel Jetstream](https://jetstream.laravel.com) authentication scaffolding, Bcrypt will be used for registration and authentication by default.
1111

1212
> {tip} Bcrypt is a great choice for hashing passwords because its "work factor" is adjustable, which means that the time it takes to generate a hash can be increased as hardware power increases.
1313
@@ -71,7 +71,7 @@ If you are using the Argon2 algorithm, the `make` method allows you to manage th
7171
7272
#### Verifying A Password Against A Hash
7373

74-
The `check` method allows you to verify that a given plain-text string corresponds to a given hash. However, if you are using the `LoginController` [included with Laravel](/docs/{{version}}/authentication), you will probably not need to use this directly, as this controller automatically calls this method:
74+
The `check` method allows you to verify that a given plain-text string corresponds to a given hash:
7575

7676
if (Hash::check('plain-text', $hashedPassword)) {
7777
// The passwords match...

helpers.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
227227
[dump](#method-dump)
228228
[env](#method-env)
229229
[event](#method-event)
230-
[factory](#method-factory)
231230
[filled](#method-filled)
232231
[info](#method-info)
233232
[logger](#method-logger)

migrations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ When you execute this command, Laravel will write a "schema" file to your `datab
6060

6161
You should commit your database schema file to source control so that other new developers on your team may quickly create your application's initial database structure.
6262

63-
> {note} Migration squashing is only available for the MySQL and PostgreSQL databases.
63+
> {note} Migration squashing is only available for the MySQL, PostgreSQL, and SQLite databases.
6464
6565
<a name="migration-structure"></a>
6666
## Migration Structure

0 commit comments

Comments
 (0)