Files
pterodactyl-panel/app/Http/Middleware/RedirectIfAuthenticated.php
T

35 lines
749 B
PHP
Raw Normal View History

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;
2017-10-29 12:37:25 -05:00
use Illuminate\Auth\AuthManager;
2026-10-05 18:10:18 -04:00
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
2015-12-06 13:58:49 -05:00
class RedirectIfAuthenticated
{
2017-10-29 12:37:25 -05:00
/**
* RedirectIfAuthenticated constructor.
*/
2026-10-05 18:10:18 -04:00
public function __construct(private readonly AuthManager $authManager) {}
2017-10-29 12:37:25 -05:00
2015-12-06 13:58:49 -05:00
/**
* 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
{
2017-10-29 12:37:25 -05:00
if ($this->authManager->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);
}
}