From b3800fc42e97bcea79cc57cef78788138309a47d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 24 May 2024 14:15:16 +0200 Subject: [PATCH] init policies --- app/Livewire/Project/Shared/Danger.php | 1 + app/Policies/ApplicationPolicy.php | 69 ++++++++++++++++++++++ app/Policies/ServicePolicy.php | 79 ++++++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 app/Policies/ApplicationPolicy.php create mode 100644 app/Policies/ServicePolicy.php diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php index 2ed764cd1..158549b06 100644 --- a/app/Livewire/Project/Shared/Danger.php +++ b/app/Livewire/Project/Shared/Danger.php @@ -24,6 +24,7 @@ class Danger extends Component public function delete() { try { + // $this->authorize('delete', $this->resource); $this->resource->delete(); DeleteResourceJob::dispatch($this->resource, $this->delete_configurations); return redirect()->route('project.resource.index', [ diff --git a/app/Policies/ApplicationPolicy.php b/app/Policies/ApplicationPolicy.php new file mode 100644 index 000000000..860479a94 --- /dev/null +++ b/app/Policies/ApplicationPolicy.php @@ -0,0 +1,69 @@ +isAdmin()) { + return true; + } + return false; + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Application $application): bool + { + return true; + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Application $application): bool + { + return true; + } +} diff --git a/app/Policies/ServicePolicy.php b/app/Policies/ServicePolicy.php new file mode 100644 index 000000000..93882be9a --- /dev/null +++ b/app/Policies/ServicePolicy.php @@ -0,0 +1,79 @@ +isAdmin()) { + return true; + } + return false; + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Service $service): bool + { + return true; + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Service $service): bool + { + if ($user->isAdmin()) { + return true; + } + return false; + } + public function stop(User $user, Service $service): bool + { + if ($user->isAdmin()) { + return true; + } + return false; + } +}