Files
pterodactyl-panel/app/Http/Middleware/RedirectIfAuthenticated.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

35 lines
749 B
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Auth\AuthManager;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class RedirectIfAuthenticated
{
/**
* RedirectIfAuthenticated constructor.
*/
public function __construct(private readonly AuthManager $authManager) {}
/**
* Handle an incoming request.
*/
/**
* @param Closure(Request):Response $next
* @return Response
*/
public function handle(Request $request, Closure $next, ?string $guard = null): mixed
{
if ($this->authManager->guard($guard)->check()) {
return to_route('index');
}
return $next($request);
}
}