Skip to content

Commit 7305647

Browse files
Explain redirectUsersTo functionality (#10253)
* Explain redirectUsersTo functionality * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 092db4e commit 7305647

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

authentication.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Route::get('/flights', function () {
189189
<a name="redirecting-unauthenticated-users"></a>
190190
#### Redirecting Unauthenticated Users
191191

192-
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:
192+
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:
193193

194194
```php
195195
use Illuminate\Http\Request;
@@ -202,6 +202,22 @@ use Illuminate\Http\Request;
202202
})
203203
```
204204

205+
<a name="redirecting-authenticated-users"></a>
206+
#### Redirecting Authenticated Users
207+
208+
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:
209+
210+
```php
211+
use Illuminate\Http\Request;
212+
213+
->withMiddleware(function (Middleware $middleware) {
214+
$middleware->redirectUsersTo('/panel');
215+
216+
// Using a closure...
217+
$middleware->redirectUsersTo(fn (Request $request) => route('panel'));
218+
})
219+
```
220+
205221
<a name="specifying-a-guard"></a>
206222
#### Specifying a Guard
207223

0 commit comments

Comments
 (0)