coolify/app/Livewire/Project/Shared/UploadConfig.php
Andras Bacsai 68f81df0bb refactor(auth): enforce authorization checks across livewire components
Add authorization checks to multiple Livewire components to ensure users
have proper permissions before performing sensitive operations. This includes:

- Adding AuthorizesRequests trait to components handling deployments, backups,
  services, and configuration uploads
- Enforcing 'deploy', 'update', and 'manageBackups' authorization checks
- Adding instance admin check for system upgrade operations
- Improving database queries with team ownership scope
- Moving backup trigger from component to button with new backupNow() method
2026-02-27 11:59:26 +01:00

48 lines
1.1 KiB
PHP

<?php
namespace App\Livewire\Project\Shared;
use App\Models\Application;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;
class UploadConfig extends Component
{
use AuthorizesRequests;
public $config;
public $applicationId;
public function mount()
{
if (isDev()) {
$this->config = '{
"build_pack": "nixpacks",
"base_directory": "/nodejs",
"publish_directory": "/",
"ports_exposes": "3000",
"settings": {
"is_static": false
}
}';
}
}
public function uploadConfig()
{
try {
$application = Application::ownedByCurrentTeam()->findOrFail($this->applicationId);
$this->authorize('update', $application);
$application->setConfig($this->config);
$this->dispatch('success', 'Application settings updated');
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function render()
{
return view('livewire.project.shared.upload-config');
}
}