Skip to content

Commit

Permalink
Update review policy to limit location access #8
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroberts authored Mar 24, 2021
1 parent f513d3a commit 7b2c920
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Policies/ReviewPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace Tipoff\Reviews\Policies;

use Illuminate\Auth\Access\HandlesAuthorization;
use Tipoff\Locations\Traits\HasLocationPermissions;
use Tipoff\Reviews\Models\Review;
use Tipoff\Support\Contracts\Models\UserInterface;

class ReviewPolicy
{
use HandlesAuthorization;
use HasLocationPermissions;

public function viewAny(UserInterface $user): bool
{
Expand All @@ -17,7 +19,7 @@ public function viewAny(UserInterface $user): bool

public function view(UserInterface $user, Review $review): bool
{
return $user->hasPermissionTo('view reviews') ? true : false;
return $this->hasLocationPermission($user, 'view reviews', $review->location_id);
}

public function create(UserInterface $user): bool
Expand All @@ -27,7 +29,7 @@ public function create(UserInterface $user): bool

public function update(UserInterface $user, Review $review): bool
{
return $user->hasPermissionTo('update reviews') ? true : false;
return $this->hasLocationPermission($user, 'update reviews', $review->location_id);
}

public function delete(UserInterface $user, Review $review): bool
Expand Down

0 comments on commit 7b2c920

Please sign in to comment.