Fix firewall API auth: load config from Server model directly
This commit is contained in:
@@ -323,7 +323,10 @@ class Firewall extends Component
|
||||
|
||||
protected function firewallRequest(string $url, string $method = 'get', array $data = []): \Illuminate\Http\Client\Response
|
||||
{
|
||||
$proxmox = new \Paymenter\Extensions\Servers\Proxmox\Proxmox;
|
||||
// Load config from the Server model directly (avoids debug_backtrace() class resolution issue)
|
||||
$serverModel = \App\Models\Server::where('extension', 'Proxmox')->first();
|
||||
$config = $serverModel ? $serverModel->settings->pluck('value', 'key')->toArray() : [];
|
||||
$proxmox = new \Paymenter\Extensions\Servers\Proxmox\Proxmox($config);
|
||||
$baseUrl = rtrim($proxmox->config('host'), '/');
|
||||
$authToken = 'PVEAPIToken=' . $proxmox->config('user') . '=' . $proxmox->config('token');
|
||||
$verifySsl = $proxmox->config('verify_ssl') ? true : false;
|
||||
@@ -519,10 +522,17 @@ class Firewall extends Component
|
||||
$this->firewallEnabled = $newState;
|
||||
$this->notify('Firewall ' . ($newState ? 'enabled' : 'disabled'), 'success');
|
||||
} else {
|
||||
// Show detailed error message from API
|
||||
// Log detailed error info for debugging
|
||||
Log::error('Firewall toggle failed', [
|
||||
'status' => $response->status(),
|
||||
'body' => substr($response->body(), 0, 500),
|
||||
'url' => '/nodes/' . $this->server->node->name . '/' . $this->server->node->vmType() . '/' . $this->server->vm_id . '/firewall/options',
|
||||
'headers' => $response->headers(),
|
||||
]);
|
||||
|
||||
$errorBody = $response->json();
|
||||
$errorMsg = $errorBody['errors'] ?? $response->body();
|
||||
$this->error = 'Failed to toggle firewall (Status ' . $response->status() . '): ' . (is_array($errorMsg) ? json_encode($errorMsg) : $errorMsg);
|
||||
$this->error = 'Failed to toggle firewall (Status ' . $response->status() . '): ' . (is_array($errorMsg) ? json_encode($errorMsg) : substr((string)$errorMsg, 0, 200));
|
||||
$this->showErrorModal = true;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user