Skip to content

Commit

Permalink
fix permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
pachonjcl committed May 6, 2024
1 parent 0076676 commit fd0257f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/Policies/V2/Nurseries/NurseryPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class NurseryPolicy extends Policy
{
public function read(?User $user, ?Nursery $nursey = null): bool
{
if ($this->isAdmin($user)) {
return true;
}

if ($user->can('framework-' . $nursey->framework_key)) {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions app/Policies/V2/Nurseries/NurseryReportPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class NurseryReportPolicy extends Policy
{
public function read(?User $user, ?NurseryReport $report = null): bool
{
if ($this->isAdmin($user)) {
return true;
}

if ($user->can('framework-' . $report->framework_key)) {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions app/Policies/V2/Projects/ProjectPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class ProjectPolicy extends Policy
{
public function read(?User $user, ?Project $project = null): bool
{
if ($this->isAdmin($user)) {
return true;
}

if ($user->can('framework-' . $project->framework_key)) {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions app/Policies/V2/Projects/ProjectReportPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class ProjectReportPolicy extends Policy
{
public function read(?User $user, ?ProjectReport $report = null): bool
{
if ($this->isAdmin($user)) {
return true;
}

if ($user->can('framework-' . $report->framework_key)) {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions app/Policies/V2/Sites/SitePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class SitePolicy extends Policy
{
public function read(?User $user, ?Site $site = null): bool
{
if ($this->isAdmin($user)) {
return true;
}

if ($user->can('framework-' . $site->framework_key)) {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions app/Policies/V2/Sites/SiteReportPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class SiteReportPolicy extends Policy
{
public function read(?User $user, ?SiteReport $report = null): bool
{
if ($this->isAdmin($user)) {
return true;
}

if ($user->can('framework-' . $report->framework_key)) {
return true;
}
Expand Down
6 changes: 5 additions & 1 deletion app/Policies/V2/Tasks/TaskPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class TaskPolicy extends Policy
{
public function read(?User $user, ?Task $task = null): bool
{
if ($this->isAdmin($user)) {
return true;
}

if ($user->can('framework-' . $task->project->framework_key)) {
return true;
}
Expand All @@ -24,7 +28,7 @@ public function read(?User $user, ?Task $task = null): bool

public function readAll(?User $user, ?Task $task = null): bool
{
return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']);
return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']) || $this->isAdmin($user);
}

public function update(?User $user, ?Task $task = null): bool
Expand Down

0 comments on commit fd0257f

Please sign in to comment.