From 877241d69931b1f43013cd09ba964b87585f36cc Mon Sep 17 00:00:00 2001 From: 1Day Date: Fri, 12 Aug 2022 13:30:15 +0200 Subject: [PATCH] test client api key button --- app/Classes/Pterodactyl.php | 9 +++++++++ app/Classes/Settings/System.php | 7 +++++++ resources/views/admin/settings/tabs/system.blade.php | 1 + routes/web.php | 4 ++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/Classes/Pterodactyl.php b/app/Classes/Pterodactyl.php index 4d81edf2..f217bd34 100644 --- a/app/Classes/Pterodactyl.php +++ b/app/Classes/Pterodactyl.php @@ -344,6 +344,15 @@ class Pterodactyl ]); } + /** + * Get info about user + */ + public static function getClientUser() + { + return self::clientAdmin()->get("/client/account"); + } + + /** * Check if node has enough free resources to allocate the given resources * @param Node $node diff --git a/app/Classes/Settings/System.php b/app/Classes/Settings/System.php index 609ad6aa..63266ad4 100644 --- a/app/Classes/Settings/System.php +++ b/app/Classes/Settings/System.php @@ -2,6 +2,7 @@ namespace App\Classes\Settings; +use App\Classes\Pterodactyl; use App\Models\Settings; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; @@ -16,7 +17,12 @@ class System return; } +public function checkPteroClientkey(){ + $response = Pterodactyl::getClientUser(); + if ($response->failed()){ return redirect()->back()->with('error', __('Your Key or URL is not correct')); } + return redirect()->back()->with('success', __('Everything is good!')); +} public function updateSettings(Request $request) { @@ -79,6 +85,7 @@ class System return redirect(route('admin.settings.index') . '#system')->with('success', __('System settings updated!')); } + private function updateIcons(Request $request) { $request->validate([ diff --git a/resources/views/admin/settings/tabs/system.blade.php b/resources/views/admin/settings/tabs/system.blade.php index 284cdcc6..f5f2df70 100644 --- a/resources/views/admin/settings/tabs/system.blade.php +++ b/resources/views/admin/settings/tabs/system.blade.php @@ -92,6 +92,7 @@ type="text" value="{{ config('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') }}" class="form-control @error('pterodactyl-admin-api-key') is-invalid @enderror" required> + diff --git a/routes/web.php b/routes/web.php index 5ece4b0b..59e0d67f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -147,7 +147,7 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { #settings Route::get('settings/datatable', [SettingsController::class, 'datatable'])->name('settings.datatable'); Route::patch('settings/updatevalue', [SettingsController::class, 'updatevalue'])->name('settings.updatevalue'); - + Route::get("settings/checkPteroClientkey", [System::class, 'checkPteroClientkey'])->name('settings.checkPteroClientkey'); #settings Route::patch('settings/update/invoice-settings', [Invoices::class, 'updateSettings'])->name('settings.update.invoicesettings'); Route::patch('settings/update/language', [Language::class, 'updateSettings'])->name('settings.update.languagesettings'); @@ -158,7 +158,7 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { #invoices Route::get('invoices/download-invoices', [InvoiceController::class, 'downloadAllInvoices'])->name('invoices.downloadAllInvoices');; - Route::get('invoices/download-single-invoice', [InvoiceController::class, 'downloadSingleInvoice'])->name('invoices.downloadSingleInvoice');; + Route::get('invoices/download-single-invoice', [InvoiceController::class, 'downloadSingleInvoice'])->name('invoices.downloadSingleInvoice'); #usefullinks Route::get('usefullinks/datatable', [UsefulLinkController::class, 'datatable'])->name('usefullinks.datatable');