Skip to content

Commit

Permalink
fix: view results of global polls, allow voting for normal users
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Mar 14, 2024
1 parent 988624d commit cc09bb8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Access/PollPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function seeVoteCount(User $actor, Poll $poll)
return $this->deny();
}

if ($poll->myVotes($actor)->count() || $actor->can('polls.viewResultsWithoutVoting', $poll->post !== null ? $poll->post->discussion : null)) {
if ($poll->myVotes($actor)->count() || $actor->can('polls.viewResultsWithoutVoting', $poll->post !== null ? $poll->post->discussion : null) || $poll->isGlobal()) {
return $this->allow();
}
}
Expand All @@ -41,7 +41,7 @@ public function seeVoters(User $actor, Poll $poll)

public function view(User $actor, Poll $poll)
{
if ($actor->can('view', $poll->post)) {
if ($actor->can('view', $poll->post) || $poll->isGlobal()) {
return $this->allow();
}
}
Expand All @@ -51,7 +51,7 @@ public function vote(User $actor, Poll $poll)
$discussion = $poll->post !== null ? $poll->post->discussion : null;
$can = $discussion ? $actor->can('polls.vote', $discussion) : $actor->can('discussion.polls.vote', $discussion);

if ($can && !$poll->hasEnded()) {
if (($can || $poll->isGlobal()) && !$poll->hasEnded()) {
return $this->allow();
}
}
Expand Down

0 comments on commit cc09bb8

Please sign in to comment.