Skip to content

Commit

Permalink
check if judging is active on OsuAuthorize level
Browse files Browse the repository at this point in the history
  • Loading branch information
venix12 committed Sep 23, 2023
1 parent 8ec451f commit 4a395fe
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
4 changes: 0 additions & 4 deletions app/Http/Controllers/ContestEntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public function judgeVote($id)
->with('judgeVotes')
->findOrFail($id);

if (!$entry->contest->isJudgingActive()) {
throw new InvariantException(osu_trans('contest.judge.validation.judging_not_active'));
}

priv_check('ContestJudge', $entry->contest)->ensureCan();

$params = get_params(request()->all(), null, [
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ContestsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function judge($id)
->with('judgeCategories')
->findOrFail($id);

abort_if(!$contest->isJudgingActive(), 404);
abort_if(!$contest->isJudged(), 404);

priv_check('ContestJudge', $contest)->ensureCan();

Expand Down
4 changes: 4 additions & 0 deletions app/Libraries/OsuAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,10 @@ public function checkContestJudge(?User $user, Contest $contest): string
{
$this->ensureLoggedIn($user);

if (!$contest->isJudgingActive()) {
return 'contest.judging_not_active';
}

if ($contest->judges->find($user->getKey()) === null) {
return 'unauthorized';
}
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
],

'contest' => [
'judging_not_active' => 'Judging for this contest isn\'t active.',
'voting_over' => 'You cannot change your vote after the voting period for this contest has ended.',

'entry' => [
Expand Down
1 change: 0 additions & 1 deletion resources/lang/en/contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
'update' => 'update',
'validation' => [
'contest_vote_judged' => 'can\'t vote in judged contests',
'judging_not_active' => 'judging for this contest isn\'t active',
'missing_category_vote' => 'missing category vote',
],
],
Expand Down
2 changes: 1 addition & 1 deletion resources/views/contests/voting.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{{ $noVoteReason }}
</div>

@if ($contestMeta->isJudgingActive() && priv_check('ContestJudge', $contestMeta)->can())
@if ($contestMeta->isJudged() && priv_check('ContestJudge', $contestMeta)->can())
<div class='contest__voting-notice'>
<a href="{{ route('contests.judge', $contestMeta) }}" target="_blank">{{osu_trans('contest.voting.judge_link')}}</a>
</div>
Expand Down

0 comments on commit 4a395fe

Please sign in to comment.