From 86e7d0707876ac18a323bf87e61d338869a03597 Mon Sep 17 00:00:00 2001 From: Marijn Doeve Date: Sat, 9 May 2026 17:17:50 +0200 Subject: [PATCH] Actual hotfix --- .gitignore | 13 +++++++++++++ AGENTS.md | 13 +++++++++++++ src/Controller/LoginController.php | 5 +++++ src/Controller/RegistrationController.php | 5 +++++ src/Service/QuizSpreadsheetService.php | 14 +++++++++----- 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 845ecd4..e7b351e 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,19 @@ Icon # Thumbnails ._* +# IDEs +/.idea/ +/.vscode/ + +# Junie +!/.junie/ +/.junie/memory/ +/.junie/plans/ + +# Windows +Thumbs.db +Desktop.ini + # Files that might appear in the root of a volume .DocumentRevisions-V100 .fseventsd diff --git a/AGENTS.md b/AGENTS.md index 1c9bcd0..94ba767 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -61,6 +61,19 @@ The project uses `just` as the primary task runner. Always prefer `just` command - CSS/Sass is in `assets/styles/`. - Assets are compiled on-the-fly or mapped; do not look for a `node_modules` folder. +## Key Components +### Controllers +- **Backoffice**: Located in `src/Controller/Backoffice`, handles season and quiz management. +- **Quiz**: `src/Controller/QuizController` handles the candidate-facing side of quizzes. +- **Elimination**: `src/Controller/EliminationController` handles elimination screens. + +### Services +- **QuizSpreadsheetService**: Handles importing quizzes from XLSX files. + +### Base Classes & Enums +- **AbstractController**: Base class for all controllers, containing common regexes and flash helpers. +- **FlashType Enum**: Used for consistent flash messaging (`FlashType::Success`, `FlashType::Danger`, etc.). + ## Key Files - `composer.json`: Dependency management. - `importmap.php`: JavaScript module mapping. diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index 946d75b..477b4ee 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Attribute\AsController; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Core\Exception\AuthenticationException; +use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; use Symfony\Contracts\Translation\TranslatorInterface; use Tvdt\Enum\FlashType; @@ -20,6 +21,10 @@ final class LoginController extends AbstractController #[Route(path: '/login', name: 'tvdt_login_login')] public function login(): Response { + if ($this->getUser() instanceof UserInterface) { + return $this->redirectToRoute('tvdt_backoffice_index'); + } + // get the login error if there is one $error = $this->authenticationUtils->getLastAuthenticationError(); // last username entered by the user diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 616804c..250ffe5 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Mailer\Exception\TransportExceptionInterface; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Contracts\Translation\TranslatorInterface; use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface; use Tvdt\Entity\User; @@ -30,6 +31,10 @@ final class RegistrationController extends AbstractController public function register( Request $request, ): Response { + if ($this->getUser() instanceof UserInterface) { + return $this->redirectToRoute('tvdt_backoffice_index'); + } + $user = new User(); $form = $this->createForm(RegistrationFormType::class, $user); $form->handleRequest($request); diff --git a/src/Service/QuizSpreadsheetService.php b/src/Service/QuizSpreadsheetService.php index 7a1178d..92e9eab 100644 --- a/src/Service/QuizSpreadsheetService.php +++ b/src/Service/QuizSpreadsheetService.php @@ -95,11 +95,15 @@ class QuizSpreadsheetService $arrCounter = 1; while (true) { - if (null === $questionArr[$arrCounter]) { - if (1 === $answerCounter) { - $errors[] = \sprintf('Question %d has no answers', $answerCounter); - } + try { + if (null === $questionArr[$arrCounter]) { + if (1 === $answerCounter) { + $errors[] = \sprintf('Question %d has no answers', $answerCounter); + } + break; + } + } catch (\ErrorException) { break; } @@ -130,6 +134,6 @@ class QuizSpreadsheetService private function isSpreadsheetFile(File $file): bool { - return 'xlsx' === $file->getExtension(); + return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' === $file->getMimeType(); } }