cyberpanel/aiScanner
usmannasir 569554e7f0 Fix VPS API key persistence in CyberPanel database
Problem: VPS API keys were generated dynamically but never saved to the database,
causing file fix operations to fail with "Invalid token" error.

Root Cause:
- When CyberPanel runs on VPS, it calls platform's /api/vps/generate-api-key/
- The returned API key was used for scan submission but not persisted
- Later file fix operations couldn't validate this API key

Solution:
- Save VPS API key to ai_scanner_settings table whenever obtained
- Modified 4 locations where VPS API key is retrieved:
  1. startScan() - Save when initiating a scan
  2. getPlatformMonitorUrl() - Save when checking scan status
  3. addPaymentMethod() - Save when configuring payment (2 locations)

Implementation:
- Use get_or_create() to ensure scanner settings exist
- Update existing settings if API key is empty or different
- Set is_payment_configured=True for VPS accounts (implicit payment)
- Continue operation even if saving fails (non-blocking)

Result:
- VPS API keys are automatically persisted on first use
- File fixes work without manual database intervention
- All AI Scanner features work seamlessly on VPS instances
2025-10-27 14:25:47 +05:00
..
management Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
migrations add aiscanner file patcher 2025-10-26 01:56:36 +05:00
templates/aiScanner enable dark mode 2025-08-05 01:47:22 +05:00
__init__.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
admin.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
aiScannerManager.py Fix VPS API key persistence in CyberPanel database 2025-10-27 14:25:47 +05:00
api.py Fix backup file operation failures for API key authentication 2025-10-27 14:16:01 +05:00
apps.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
models.py add aiscanner file patcher 2025-10-26 01:56:36 +05:00
scheduled_views.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
status_api.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
status_models.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
test_api_endpoint.py Fix CyberPanel API key validation for platform callbacks 2025-10-27 13:51:33 +05:00
tests.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
urls.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
views.py Fix VPS API key persistence in CyberPanel database 2025-10-27 14:25:47 +05:00