feat(auth): implement authorization checks for database management

This commit is contained in:
Andras Bacsai
2025-08-23 18:50:35 +02:00
parent 6d02f6a60b
commit adb8f9d88e
17 changed files with 281 additions and 27 deletions

View File

@@ -7,10 +7,13 @@ use App\Actions\Database\StartDatabase;
use App\Actions\Database\StopDatabase;
use App\Actions\Docker\GetContainersStatus;
use App\Events\ServiceStatusChanged;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;
class Heading extends Component
{
use AuthorizesRequests;
public $database;
public array $parameters;
@@ -67,6 +70,8 @@ class Heading extends Component
public function stop()
{
try {
$this->authorize('manage', $this->database);
$this->dispatch('info', 'Gracefully stopping database.');
StopDatabase::dispatch($this->database, false, $this->docker_cleanup);
} catch (\Exception $e) {
@@ -76,12 +81,16 @@ class Heading extends Component
public function restart()
{
$this->authorize('manage', $this->database);
$activity = RestartDatabase::run($this->database);
$this->dispatch('activityMonitor', $activity->id, ServiceStatusChanged::class);
}
public function start()
{
$this->authorize('manage', $this->database);
$activity = StartDatabase::run($this->database);
$this->dispatch('activityMonitor', $activity->id, ServiceStatusChanged::class);
}