From 11788cee93e49dd1b239481587524c435849c7e1 Mon Sep 17 00:00:00 2001 From: Sasa Tokic Date: Thu, 7 Dec 2023 12:20:23 +0100 Subject: [PATCH] actually check permissions... --- config/sales-management.php | 1 + src/Policies/SalesManagementPolicy.php | 4 + .../SalesManagementPolicyContract.php | 2 + src/SalesManagementServiceProvider.php | 21 ++-- .../views/campaign/actions.blade.php | 4 +- src/resources/views/campaign/show.blade.php | 6 +- .../partials/left-navigation.blade.php | 16 +-- src/resources/views/messages/index.blade.php | 2 +- src/resources/views/workflows/index.blade.php | 2 +- src/routes/web.php | 117 +++++++++++------- 10 files changed, 104 insertions(+), 71 deletions(-) diff --git a/config/sales-management.php b/config/sales-management.php index 94826ec..70080cf 100644 --- a/config/sales-management.php +++ b/config/sales-management.php @@ -6,6 +6,7 @@ 'logoLink' => '/', 'tablePrefix' => 'sales_management_', 'prefix' => '', + 'permission_prefix' => 'sales_management', 'middleware' => ['web', 'auth'], 'userModel' => \App\Models\User::class, 'emails' => [ diff --git a/src/Policies/SalesManagementPolicy.php b/src/Policies/SalesManagementPolicy.php index aacaf49..c9a4206 100644 --- a/src/Policies/SalesManagementPolicy.php +++ b/src/Policies/SalesManagementPolicy.php @@ -48,6 +48,10 @@ public function viewMessages() { return true; } + public function viewActivities() + { + return true; + } public function sendEmails() { diff --git a/src/Policies/SalesManagementPolicyContract.php b/src/Policies/SalesManagementPolicyContract.php index 55e2c34..d63fb99 100644 --- a/src/Policies/SalesManagementPolicyContract.php +++ b/src/Policies/SalesManagementPolicyContract.php @@ -23,4 +23,6 @@ public function viewWorkflows(); public function viewMessages(); public function sendEmails(); + + public function viewActivities(); } diff --git a/src/SalesManagementServiceProvider.php b/src/SalesManagementServiceProvider.php index 81da746..e7ad5dc 100644 --- a/src/SalesManagementServiceProvider.php +++ b/src/SalesManagementServiceProvider.php @@ -74,15 +74,16 @@ public function loadViewComponents() public function defineAbilities() { - Gate::define(config('sales-management.prefix') . '.view-dashboard', [config('sales-management.policy'), 'viewDashboard']); - Gate::define(config('sales-management.prefix') . '.view-contacts', [config('sales-management.policy'), 'viewContacts']); - Gate::define(config('sales-management.prefix') . '.view-lists', [config('sales-management.policy'), 'viewLists']); - Gate::define(config('sales-management.prefix') . '.view-campaigns', [config('sales-management.policy'), 'viewCampaigns']); - Gate::define(config('sales-management.prefix') . '.view-pipelines', [config('sales-management.policy'), 'viewPipelines']); - Gate::define(config('sales-management.prefix') . '.view-tags', [config('sales-management.policy'), 'viewTags']); - Gate::define(config('sales-management.prefix') . '.view-docs', [config('sales-management.policy'), 'viewDocs']); - Gate::define(config('sales-management.prefix') . '.view-workflows', [config('sales-management.policy'), 'viewWorkflows']); - Gate::define(config('sales-management.prefix') . '.view-messages', [config('sales-management.policy'), 'viewMessages']); - Gate::define(config('sales-management.prefix') . '.send-emails', [config('sales-management.policy'), 'sendEmails']); + Gate::define(config('sales-management.permission_prefix') . '.view-dashboard', [config('sales-management.policy'), 'viewDashboard']); + Gate::define(config('sales-management.permission_prefix') . '.view-contacts', [config('sales-management.policy'), 'viewContacts']); + Gate::define(config('sales-management.permission_prefix') . '.view-lists', [config('sales-management.policy'), 'viewLists']); + Gate::define(config('sales-management.permission_prefix') . '.view-campaigns', [config('sales-management.policy'), 'viewCampaigns']); + Gate::define(config('sales-management.permission_prefix') . '.view-pipelines', [config('sales-management.policy'), 'viewPipelines']); + Gate::define(config('sales-management.permission_prefix') . '.view-tags', [config('sales-management.policy'), 'viewTags']); + Gate::define(config('sales-management.permission_prefix') . '.view-docs', [config('sales-management.policy'), 'viewDocs']); + Gate::define(config('sales-management.permission_prefix') . '.view-workflows', [config('sales-management.policy'), 'viewWorkflows']); + Gate::define(config('sales-management.permission_prefix') . '.view-messages', [config('sales-management.policy'), 'viewMessages']); + Gate::define(config('sales-management.permission_prefix') . '.send-emails', [config('sales-management.policy'), 'sendEmails']); + Gate::define(config('sales-management.permission_prefix') . '.view-activities', [config('sales-management.policy'), 'viewActivities']); } } diff --git a/src/resources/views/campaign/actions.blade.php b/src/resources/views/campaign/actions.blade.php index 64981f6..6369408 100644 --- a/src/resources/views/campaign/actions.blade.php +++ b/src/resources/views/campaign/actions.blade.php @@ -6,10 +6,10 @@