From 05591af744e1977ad46d0e0cf39ac56eb089fd78 Mon Sep 17 00:00:00 2001 From: Jose Carlos Laura Ramirez Date: Wed, 21 Aug 2024 13:46:04 -0400 Subject: [PATCH] [TM-1171] fix role policy check --- app/Policies/V2/Nurseries/NurseryPolicy.php | 2 +- app/Policies/V2/Nurseries/NurseryReportPolicy.php | 2 +- app/Policies/V2/Projects/ProjectPolicy.php | 2 +- app/Policies/V2/Projects/ProjectReportPolicy.php | 2 +- app/Policies/V2/Sites/SitePolicy.php | 2 +- app/Policies/V2/Sites/SiteReportPolicy.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Policies/V2/Nurseries/NurseryPolicy.php b/app/Policies/V2/Nurseries/NurseryPolicy.php index 20ddd3001..299ac7c1c 100644 --- a/app/Policies/V2/Nurseries/NurseryPolicy.php +++ b/app/Policies/V2/Nurseries/NurseryPolicy.php @@ -122,7 +122,7 @@ public function approve(?User $user, ?Nursery $nursery = null): bool public function export(?User $user, ?Form $form = null, ?Project $project = null): bool { - if ($user->primaryRole?->name == 'project-manager') { + if ($user->hasRole('project-manager')) { return $user->my_frameworks_slug->contains($form->framework_key); } diff --git a/app/Policies/V2/Nurseries/NurseryReportPolicy.php b/app/Policies/V2/Nurseries/NurseryReportPolicy.php index 5ffa6ff58..7949f40c0 100644 --- a/app/Policies/V2/Nurseries/NurseryReportPolicy.php +++ b/app/Policies/V2/Nurseries/NurseryReportPolicy.php @@ -132,7 +132,7 @@ protected function isManagingProject(User $user, Project $project): bool public function export(?User $user, ?Form $form = null, ?Project $project = null): bool { - if ($user->primaryRole?->name == 'project-manager') { + if ($user->hasRole('project-manager')) { return $user->my_frameworks_slug->contains($form->framework_key); } diff --git a/app/Policies/V2/Projects/ProjectPolicy.php b/app/Policies/V2/Projects/ProjectPolicy.php index 874ae1f13..ce3e89175 100644 --- a/app/Policies/V2/Projects/ProjectPolicy.php +++ b/app/Policies/V2/Projects/ProjectPolicy.php @@ -186,7 +186,7 @@ protected function isManaging(?User $user, ?Project $project = null): bool public function export(?User $user, ?Form $form = null, ?Project $project = null): bool { - if ($user->primaryRole?->name == 'project-manager') { + if ($user->hasRole('project-manager')) { return $user->my_frameworks_slug->contains($form->framework_key); } diff --git a/app/Policies/V2/Projects/ProjectReportPolicy.php b/app/Policies/V2/Projects/ProjectReportPolicy.php index 0fc4ca547..70ee035a1 100644 --- a/app/Policies/V2/Projects/ProjectReportPolicy.php +++ b/app/Policies/V2/Projects/ProjectReportPolicy.php @@ -128,7 +128,7 @@ protected function isManagingProject(User $user, Project $project): bool public function export(?User $user, ?Form $form = null, ?Project $project = null): bool { - if ($user->primaryRole?->name == 'project-manager') { + if ($user->hasRole('project-manager')) { return $user->my_frameworks_slug->contains($form->framework_key); } diff --git a/app/Policies/V2/Sites/SitePolicy.php b/app/Policies/V2/Sites/SitePolicy.php index 95ad73d82..8780787f1 100644 --- a/app/Policies/V2/Sites/SitePolicy.php +++ b/app/Policies/V2/Sites/SitePolicy.php @@ -159,7 +159,7 @@ public function uploadPolygons(?User $user, ?Site $site): bool public function export(?User $user, ?Form $form = null, ?Project $project = null): bool { - if ($user->primaryRole?->name == 'project-manager') { + if ($user->hasRole('project-manager')) { return $user->my_frameworks_slug->contains($form->framework_key); } diff --git a/app/Policies/V2/Sites/SiteReportPolicy.php b/app/Policies/V2/Sites/SiteReportPolicy.php index 44041557a..7afebee4d 100644 --- a/app/Policies/V2/Sites/SiteReportPolicy.php +++ b/app/Policies/V2/Sites/SiteReportPolicy.php @@ -128,7 +128,7 @@ protected function isManagingProject(User $user, Project $project): bool public function export(?User $user, ?Form $form = null, ?Project $project = null): bool { - if ($user->primaryRole?->name == 'project-manager') { + if ($user->hasRole('project-manager')) { return $user->my_frameworks_slug->contains($form->framework_key); }