Skip to content

Commit a5d47f3

Browse files
committed
Redirect to registration page if not logged in, there is only a non-public contest and self registration is enabled.
1 parent f08b167 commit a5d47f3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

webapp/src/Controller/PublicController.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Entity\Contest;
66
use App\Entity\ContestProblem;
77
use App\Entity\Team;
8+
use App\Entity\TeamCategory;
89
use App\Service\ConfigurationService;
910
use App\Service\DOMJudgeService;
1011
use App\Service\ScoreboardService;
@@ -41,9 +42,16 @@ public function scoreboardAction(
4142
#[MapQueryParameter]
4243
?bool $static = false,
4344
): Response {
44-
$response = new Response();
45-
$refreshUrl = $this->generateUrl('public_index');
46-
$contest = $this->dj->getCurrentContest(onlyPublic: true);
45+
$response = new Response();
46+
$refreshUrl = $this->generateUrl('public_index');
47+
$contest = $this->dj->getCurrentContest(onlyPublic: true);
48+
$nonPublicContest = $this->dj->getCurrentContest(onlyPublic: false);
49+
if (!$contest && $nonPublicContest && $this->em->getRepository(TeamCategory::class)->count(['allow_self_registration' => 1])) {
50+
// This leaks a little bit of information about the existence of the non-public contest,
51+
// but since self registration is enabled, it's not a big deal.
52+
return $this->redirectToRoute('register');
53+
}
54+
4755

4856
if ($static) {
4957
$refreshParams = [

0 commit comments

Comments
 (0)