Skip to content

Commit 21c84d3

Browse files
committed
fix access check
Signed-off-by: dartcafe <github@dartcafe.de>
1 parent cefee06 commit 21c84d3

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

lib/Service/VoteService.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use OCA\Polls\Db\VoteMapper;
1717
use OCA\Polls\Event\VoteDeletedOrphanedEvent;
1818
use OCA\Polls\Event\VoteSetEvent;
19+
use OCA\Polls\Exceptions\ForbiddenException;
1920
use OCA\Polls\Exceptions\NotFoundException;
2021
use OCA\Polls\Exceptions\VoteLimitExceededException;
2122
use OCA\Polls\UserSession;
@@ -138,11 +139,13 @@ public function set(Option|int $optionOrOptionIdoptionId, string $setTo): ?Vote
138139
* @return Vote[]
139140
*/
140141
public function getOprhanedVotes(int $pollId): array {
141-
$poll = $this->pollMapper->get($pollId, withRoles: true);
142-
$poll->request(Poll::PERMISSION_POLL_EDIT);
143-
144-
// get all votes of the poll, which are not assigned to an option
145-
return $this->voteMapper->findOrphanedByPoll($pollId);
142+
try {
143+
$poll = $this->pollMapper->get($pollId, withRoles: true);
144+
$poll->request(Poll::PERMISSION_POLL_EDIT);
145+
return $this->voteMapper->findOrphanedByPoll($pollId);
146+
} catch (ForbiddenException $e) {
147+
return [];
148+
}
146149
}
147150

148151
/**

0 commit comments

Comments
 (0)