Skip to content

Commit

Permalink
Fix authorization gate checking logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurt Friars committed Mar 6, 2024
1 parent 9831426 commit 228423e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Services/PublisherService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PublisherService

public function shouldEnableDraftContent(Request $request): bool
{
if ($this->shouldCheckGate() && Gate::denies('view-draft-content')) {
if (! $this->shouldCheckGate() || Gate::denies('view-draft-content')) {
return false;
}

Expand All @@ -30,14 +30,14 @@ public function shouldEnableDraftContent(Request $request): bool

public function canPublish(Publishable&Model $model): bool
{
return $this->shouldCheckGate()
&& Gate::authorize('publish', $model);
return ! $this->shouldCheckGate()
|| Gate::authorize('publish', $model);
}

public function canUnpublish(Publishable&Model $model): bool
{
return $this->shouldCheckGate()
&& Gate::authorize('unpublish', $model);
return ! $this->shouldCheckGate()
|| Gate::authorize('unpublish', $model);
}

protected function shouldCheckGate(): bool
Expand Down

0 comments on commit 228423e

Please sign in to comment.