diff --git a/authentication.md b/authentication.md index a06f281b202..c3ce509df93 100644 --- a/authentication.md +++ b/authentication.md @@ -189,7 +189,7 @@ Route::get('/flights', function () { #### Redirecting Unauthenticated Users -When the `auth` middleware detects an unauthenticated user, it will redirect the user to the `login` [named route](/docs/{{version}}/routing#named-routes). You may modify this behavior using the method `redirectGuestsTo` of your application's `bootstrap/app.php` file: +When the `auth` middleware detects an unauthenticated user, it will redirect the user to the `login` [named route](/docs/{{version}}/routing#named-routes). You may modify this behavior using the `redirectGuestsTo` method within your application's `bootstrap/app.php` file: ```php use Illuminate\Http\Request; @@ -202,6 +202,22 @@ use Illuminate\Http\Request; }) ``` + +#### Redirecting Authenticated Users + +When the `guest` middleware detects an authenticated user, it will redirect the user to the `dashboard` or `home` named route. You may modify this behavior using the `redirectUsersTo` method within your application's `bootstrap/app.php` file: + +```php +use Illuminate\Http\Request; + +->withMiddleware(function (Middleware $middleware) { + $middleware->redirectUsersTo('/panel'); + + // Using a closure... + $middleware->redirectUsersTo(fn (Request $request) => route('panel')); +}) +``` + #### Specifying a Guard