Files
pterodactyl-panel/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php
T

30 lines
828 B
PHP
Raw Normal View History

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