Laravel 10 (#4706)

This commit is contained in:
Matthew Penner 2023-02-23 12:30:16 -07:00 committed by GitHub
parent ad4ddc6300
commit 1d38b4f0e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
136 changed files with 1735 additions and 2008 deletions

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api\Application;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@ -12,7 +11,7 @@ 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
public function handle(Request $request, \Closure $next): mixed
{
/** @var \Pterodactyl\Models\User|null $user */
$user = $request->user();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api;
use Closure;
use IPTools\IP;
use IPTools\Range;
use Illuminate\Http\Request;
@ -18,7 +17,7 @@ class AuthenticateIPAccess
* @throws \Exception
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/
public function handle(Request $request, Closure $next): mixed
public function handle(Request $request, \Closure $next): mixed
{
/** @var \Laravel\Sanctum\TransientToken|\Pterodactyl\Models\ApiKey $token */
$token = $request->user()->currentAccessToken();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api\Client\Server;
use Closure;
use Illuminate\Http\Request;
use Pterodactyl\Models\Server;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -27,7 +26,7 @@ class AuthenticateServerAccess
/**
* Authenticate that this server exists and is not suspended or marked as installing.
*/
public function handle(Request $request, Closure $next): mixed
public function handle(Request $request, \Closure $next): mixed
{
/** @var \Pterodactyl\Models\User $user */
$user = $request->user();

View file

@ -2,11 +2,9 @@
namespace Pterodactyl\Http\Middleware\Api\Client\Server;
use Closure;
use Illuminate\Http\Request;
use Pterodactyl\Models\Task;
use Pterodactyl\Models\User;
use InvalidArgumentException;
use Pterodactyl\Models\Backup;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Subuser;
@ -26,11 +24,11 @@ class ResourceBelongsToServer
* server that is expected, and that we're not accessing a resource completely
* unrelated to the server provided in the request.
*/
public function handle(Request $request, Closure $next): mixed
public function handle(Request $request, \Closure $next): mixed
{
$params = $request->route()->parameters();
if (is_null($params) || !$params['server'] instanceof Server) {
throw new InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.');
throw new \InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.');
}
/** @var \Pterodactyl\Models\Server $server */
@ -79,7 +77,7 @@ class ResourceBelongsToServer
default:
// Don't return a 404 here since we want to make sure no one relies
// on this middleware in a context in which it will not work. Fail safe.
throw new InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model));
throw new \InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model));
}
}

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api\Client;
use Closure;
use Pterodactyl\Models\Server;
use Illuminate\Routing\Middleware\SubstituteBindings;
@ -11,7 +10,7 @@ class SubstituteClientBindings extends SubstituteBindings
/**
* @param \Illuminate\Http\Request $request
*/
public function handle($request, Closure $next): mixed
public function handle($request, \Closure $next): mixed
{
// Override default behavior of the model binding to use a specific table
// column rather than the default 'id'.

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api\Daemon;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Contracts\Encryption\Encrypter;
use Pterodactyl\Repositories\Eloquent\NodeRepository;
@ -32,7 +31,7 @@ class DaemonAuthenticate
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle(Request $request, Closure $next): mixed
public function handle(Request $request, \Closure $next): mixed
{
if (in_array($request->route()->getName(), $this->except)) {
return $next($request);

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api;
use Closure;
use JsonException;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@ -14,12 +12,12 @@ class IsValidJson
* parsing the data. This avoids confusing validation errors where every field is flagged and
* it is not immediately clear that there is an issue with the JSON being passed.
*/
public function handle(Request $request, Closure $next): mixed
public function handle(Request $request, \Closure $next): mixed
{
if ($request->isJson() && !empty($request->getContent())) {
try {
json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $exception) {
} catch (\JsonException $exception) {
throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage());
}
}