Laravel 10 (#4706)
This commit is contained in:
parent
ad4ddc6300
commit
1d38b4f0e2
136 changed files with 1735 additions and 2008 deletions
|
@ -3,7 +3,6 @@
|
|||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Exception;
|
||||
use PDOException;
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@ -69,8 +68,8 @@ class DatabaseController extends Controller
|
|||
{
|
||||
try {
|
||||
$host = $this->creationService->handle($request->normalize());
|
||||
} catch (Exception $exception) {
|
||||
if ($exception instanceof PDOException || $exception->getPrevious() instanceof PDOException) {
|
||||
} catch (\Exception $exception) {
|
||||
if ($exception instanceof \PDOException || $exception->getPrevious() instanceof \PDOException) {
|
||||
$this->alert->danger(
|
||||
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
|
||||
)->flash();
|
||||
|
@ -98,10 +97,10 @@ class DatabaseController extends Controller
|
|||
try {
|
||||
$this->updateService->handle($host->id, $request->normalize());
|
||||
$this->alert->success('Database host was updated successfully.')->flash();
|
||||
} catch (Exception $exception) {
|
||||
} catch (\Exception $exception) {
|
||||
// Catch any SQL related exceptions and display them back to the user, otherwise just
|
||||
// throw the exception like normal and move on with it.
|
||||
if ($exception instanceof PDOException || $exception->getPrevious() instanceof PDOException) {
|
||||
if ($exception instanceof \PDOException || $exception->getPrevious() instanceof \PDOException) {
|
||||
$this->alert->danger(
|
||||
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
|
||||
)->flash();
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
||||
|
||||
use JavaScript;
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@ -40,7 +39,7 @@ class EggController extends Controller
|
|||
public function create(): View
|
||||
{
|
||||
$nests = $this->nestRepository->getWithEggs();
|
||||
JavaScript::put(['nests' => $nests->keyBy('id')]);
|
||||
\JavaScript::put(['nests' => $nests->keyBy('id')]);
|
||||
|
||||
return $this->view->make('admin.eggs.new', ['nests' => $nests]);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
||||
|
||||
use JavaScript;
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Models\Location;
|
||||
|
@ -45,7 +44,7 @@ class CreateServerController extends Controller
|
|||
|
||||
$nests = $this->nestRepository->getWithEggs();
|
||||
|
||||
JavaScript::put([
|
||||
\JavaScript::put([
|
||||
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
||||
'nests' => $nests->map(function ($item) {
|
||||
return array_merge($item->toArray(), [
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
||||
|
||||
use JavaScript;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Nest;
|
||||
|
@ -134,7 +133,7 @@ class ServerViewController extends Controller
|
|||
$canTransfer = true;
|
||||
}
|
||||
|
||||
JavaScript::put([
|
||||
\JavaScript::put([
|
||||
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
||||
]);
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Settings;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
@ -82,7 +81,7 @@ class MailController extends Controller
|
|||
try {
|
||||
Notification::route('mail', $request->user()->email)
|
||||
->notify(new MailTested($request->user()));
|
||||
} catch (Exception $exception) {
|
||||
} catch (\Exception $exception) {
|
||||
return response($exception->getMessage(), 500);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
||||
|
||||
use Exception;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
@ -178,7 +177,7 @@ class ScheduleController extends ClientApiController
|
|||
$request->input('month'),
|
||||
$request->input('day_of_week')
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
} catch (\Exception $exception) {
|
||||
throw new DisplayException('The cron data provided does not evaluate to a valid expression.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Remote;
|
||||
|
||||
use Exception;
|
||||
use Carbon\Carbon;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Support\Str;
|
||||
use Pterodactyl\Models\User;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
@ -37,11 +35,11 @@ class ActivityProcessingController extends Controller
|
|||
|
||||
try {
|
||||
$when = Carbon::createFromFormat(
|
||||
DateTimeInterface::RFC3339,
|
||||
\DateTimeInterface::RFC3339,
|
||||
preg_replace('/(\.\d+)Z$/', 'Z', $datum['timestamp']),
|
||||
'UTC'
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
} catch (\Exception $exception) {
|
||||
Log::warning($exception, ['timestamp' => $datum['timestamp']]);
|
||||
|
||||
// If we cannot parse the value for some reason don't blow up this request, just go ahead
|
||||
|
|
|
@ -86,7 +86,7 @@ class Kernel extends HttpKernel
|
|||
/**
|
||||
* The application's route middleware.
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
protected $middlewareAliases = [
|
||||
'auth' => Authenticate::class,
|
||||
'auth.basic' => AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => AuthenticateSession::class,
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware\Activity;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Facades\LogTarget;
|
||||
|
||||
|
@ -12,7 +11,7 @@ class AccountSubject
|
|||
* Sets the actor and default subject for all requests passing through this
|
||||
* middleware to be the currently logged in user.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
LogTarget::setActor($request->user());
|
||||
LogTarget::setSubject($request->user());
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware\Activity;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Facades\LogTarget;
|
||||
|
@ -17,7 +16,7 @@ class ServerSubject
|
|||
* If no server is found this is a no-op as the activity log service can always
|
||||
* set the user based on the authmanager response.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$server = $request->route()->parameter('server');
|
||||
if ($server instanceof Server) {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware\Activity;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\ApiKey;
|
||||
use Pterodactyl\Facades\LogTarget;
|
||||
|
@ -15,7 +14,7 @@ class TrackAPIKey
|
|||
* request singleton so that all tracked activity log events are properly associated
|
||||
* with the given API key.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
public function handle(Request $request, \Closure $next): mixed
|
||||
{
|
||||
if ($request->user()) {
|
||||
$token = $request->user()->currentAccessToken();
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware\Admin\Servers;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Server;
|
||||
|
@ -14,7 +13,7 @@ class ServerInstalled
|
|||
/**
|
||||
* Checks that the server is installed before allowing access through the route.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
public function handle(Request $request, \Closure $next): mixed
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Server|null $server */
|
||||
$server = $request->route()->parameter('server');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
|
@ -13,7 +12,7 @@ class AdminAuthenticate
|
|||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
public function handle(Request $request, \Closure $next): mixed
|
||||
{
|
||||
if (!$request->user() || !$request->user()->root_admin) {
|
||||
throw new AccessDeniedHttpException();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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'.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Foundation\Application;
|
||||
|
||||
|
@ -18,7 +17,7 @@ class LanguageMiddleware
|
|||
/**
|
||||
* Handle an incoming request and set the user's preferred language.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
public function handle(Request $request, \Closure $next): mixed
|
||||
{
|
||||
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
|
@ -18,7 +17,7 @@ class MaintenanceMiddleware
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
public function handle(Request $request, \Closure $next): mixed
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Server $server */
|
||||
$server = $request->attributes->get('server');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Auth\AuthManager;
|
||||
|
||||
|
@ -18,7 +17,7 @@ class RedirectIfAuthenticated
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string $guard = null): mixed
|
||||
public function handle(Request $request, \Closure $next, string $guard = null): mixed
|
||||
{
|
||||
if ($this->authManager->guard($guard)->check()) {
|
||||
return redirect()->route('index');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
|
@ -34,7 +33,7 @@ class RequireTwoFactorAuthentication
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\TwoFactorAuthRequiredException
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
public function handle(Request $request, \Closure $next): mixed
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = $request->user();
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use stdClass;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
@ -24,7 +22,7 @@ class VerifyReCaptcha
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
public function handle(Request $request, \Closure $next): mixed
|
||||
{
|
||||
if (!$this->config->get('recaptcha.enabled')) {
|
||||
return $next($request);
|
||||
|
@ -61,7 +59,7 @@ class VerifyReCaptcha
|
|||
/**
|
||||
* Determine if the response from the recaptcha servers was valid.
|
||||
*/
|
||||
private function isResponseVerified(stdClass $result, Request $request): bool
|
||||
private function isResponseVerified(\stdClass $result, Request $request): bool
|
||||
{
|
||||
if (!$this->config->get('recaptcha.verify_domain')) {
|
||||
return false;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Api\Client\Account;
|
||||
|
||||
use Exception;
|
||||
use phpseclib3\Crypt\DSA;
|
||||
use phpseclib3\Crypt\RSA;
|
||||
use Pterodactyl\Models\UserSSHKey;
|
||||
|
@ -71,7 +70,7 @@ class StoreSSHKeyRequest extends ClientApiRequest
|
|||
public function getKeyFingerprint(): string
|
||||
{
|
||||
if (!$this->key) {
|
||||
throw new Exception('The public key was not properly loaded for this request.');
|
||||
throw new \Exception('The public key was not properly loaded for this request.');
|
||||
}
|
||||
|
||||
return $this->key->getFingerprint('sha256');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue