2015-12-06 13:58:49 -05:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2015-12-06 13:58:49 -05:00
|
|
|
namespace Pterodactyl\Http\Middleware;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
use Closure;
|
|
|
|
|
use Illuminate\Http\Request;
|
2026-10-08 17:22:14 -04:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2015-12-06 13:58:49 -05:00
|
|
|
|
|
|
|
|
class RedirectIfAuthenticated
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Handle an incoming request.
|
|
|
|
|
*/
|
2026-10-05 18:10:18 -04:00
|
|
|
/**
|
|
|
|
|
* @param Closure(Request):Response $next
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function handle(Request $request, Closure $next, ?string $guard = null): mixed
|
2015-12-06 13:58:49 -05:00
|
|
|
{
|
2026-10-08 17:22:14 -04:00
|
|
|
if (Auth::guard($guard)->check()) {
|
2026-10-05 18:10:18 -04:00
|
|
|
return to_route('index');
|
2015-12-06 13:58:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
|
}
|
|
|
|
|
}
|