8
0
mirror of https://github.com/pelican-dev/panel.git synced 2025-08-15 11:12:14 +02:00
Matthew Penner 3ea6d45cda
php-cs-fixer
2022-11-29 10:53:59 -07:00

25 lines
730 B
PHP

<?php
namespace Pterodactyl\Http\Middleware\Api\Application;
use Illuminate\Http\Request;
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.
*/
public function handle(Request $request, \Closure $next): mixed
{
/** @var \Pterodactyl\Models\User|null $user */
$user = $request->user();
if (!$user || !$user->root_admin) {
throw new AccessDeniedHttpException('This account does not have permission to access the API.');
}
return $next($request);
}
}