Files
pterodactyl-panel/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.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

30 lines
828 B
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Http\Middleware\Api\Application;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class AuthenticateApplicationUser
{
/**
* Authenticate that the currently authenticated user is an administrator
* and should be allowed to proceed through the application API.
*/
/**
* @param Closure(Request):Response $next
* @return Response
*/
public function handle(Request $request, Closure $next): mixed
{
$user = $request->user();
throw_if(! $user || ! $user->root_admin, AccessDeniedHttpException::class, 'This account does not have permission to access the API.');
return $next($request);
}
}