develop
Last change
on this file since 43c2c15 was 2fc88ec, checked in by beratkjufliju <kufliju@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
734 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 |
|
---|
10 | class RedirectIfAuthenticated
|
---|
11 | {
|
---|
12 | /**
|
---|
13 | * Handle an incoming request.
|
---|
14 | *
|
---|
15 | * @param \Illuminate\Http\Request $request
|
---|
16 | * @param \Closure $next
|
---|
17 | * @param string|null ...$guards
|
---|
18 | * @return mixed
|
---|
19 | */
|
---|
20 | public function handle(Request $request, Closure $next, ...$guards)
|
---|
21 | {
|
---|
22 | $guards = empty($guards) ? [null] : $guards;
|
---|
23 |
|
---|
24 | foreach ($guards as $guard) {
|
---|
25 | if (Auth::guard($guard)->check()) {
|
---|
26 | return redirect(RouteServiceProvider::HOME);
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | return $next($request);
|
---|
31 | }
|
---|
32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.