feat(auth): enhance authorization checks in Livewire components for resource management

This commit is contained in:
Andras Bacsai
2025-08-24 17:14:55 +02:00
parent ae79a98d72
commit ae1b0de561
13 changed files with 184 additions and 77 deletions

View File

@@ -37,6 +37,8 @@ class Danger extends Component
public string $resourceDomain = '';
public bool $canDelete = false;
public function mount()
{
$parameters = get_route_parameters();
@@ -80,6 +82,13 @@ class Danger extends Component
'service-database' => $this->resource->name ?? 'Service Database',
default => 'Unknown Resource',
};
// Check if user can delete this resource
try {
$this->canDelete = auth()->user()->can('delete', $this->resource);
} catch (\Exception $e) {
$this->canDelete = false;
}
}
public function delete($password)