test client api key button

This commit is contained in:
1Day 2022-08-12 13:30:15 +02:00
parent b9d44b589d
commit 877241d699
4 changed files with 19 additions and 2 deletions

View file

@ -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

View file

@ -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([

View file

@ -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>
</div>
<a href="{{route('admin.settings.checkPteroClientkey')}}"> <button type="button" class="btn btn-secondary">{{__("Test API")}}</button></a>
</div>
</div>

View file

@ -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');