main
Last change
on this file since 5372778 was c454c0f, checked in by bube-ristovska <ristovska725@…>, 11 months ago |
First commit
|
-
Property mode
set to
100644
|
File size:
760 bytes
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Middleware;
|
---|
4 |
|
---|
5 | use App\Providers\RouteServiceProvider;
|
---|
6 | use Closure;
|
---|
7 | use Illuminate\Http\Request;
|
---|
8 | use Illuminate\Support\Facades\Auth;
|
---|
9 | use Symfony\Component\HttpFoundation\Response;
|
---|
10 |
|
---|
11 | class RedirectIfAuthenticated
|
---|
12 | {
|
---|
13 | /**
|
---|
14 | * Handle an incoming request.
|
---|
15 | *
|
---|
16 | * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
---|
17 | */
|
---|
18 | public function handle(Request $request, Closure $next, string ...$guards): Response
|
---|
19 | {
|
---|
20 | $guards = empty($guards) ? [null] : $guards;
|
---|
21 |
|
---|
22 | foreach ($guards as $guard) {
|
---|
23 | if (Auth::guard($guard)->check()) {
|
---|
24 | return redirect(RouteServiceProvider::HOME);
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
28 | return $next($request);
|
---|
29 | }
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.