Spaces:
Sleeping
Sleeping
Download app/Http/Middleware/RedirectIfAuthenticated.php from Anuj-Panthri/Learn-Guide: direct link, hf CLI and curl.
- Browser
- Download file 760 Bytes
-
https://huggingface.co/spaces/Anuj-Panthri/Learn-Guide/resolve/main/app/Http/Middleware/RedirectIfAuthenticated.php
- Command line
-
hf download hf://spaces/Anuj-Panthri/Learn-Guide/app/Http/Middleware/RedirectIfAuthenticated.php
-
curl -L -o RedirectIfAuthenticated.php https://huggingface.co/spaces/Anuj-Panthri/Learn-Guide/resolve/main/app/Http/Middleware/RedirectIfAuthenticated.php
760 Bytes
| namespace App\Http\Middleware; | |
| use App\Providers\RouteServiceProvider; | |
| use Closure; | |
| use Illuminate\Http\Request; | |
| use Illuminate\Support\Facades\Auth; | |
| use Symfony\Component\HttpFoundation\Response; | |
| class RedirectIfAuthenticated | |
| { | |
| /** | |
| * Handle an incoming request. | |
| * | |
| * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next | |
| */ | |
| public function handle(Request $request, Closure $next, string ...$guards): Response | |
| { | |
| $guards = empty($guards) ? [null] : $guards; | |
| foreach ($guards as $guard) { | |
| if (Auth::guard($guard)->check()) { | |
| return redirect(RouteServiceProvider::HOME); | |
| } | |
| } | |
| return $next($request); | |
| } | |
| } | |