From 1b96ec97c192e1a1715838c5d41fca036a119b4b Mon Sep 17 00:00:00 2001 From: Robert Eggl Date: Mon, 15 Apr 2024 19:35:34 +0200 Subject: [PATCH] Fixes guest only mode --- Dockerfile | 2 ++ assets/spo-parser/run.sh | 2 +- rogue-thi-app/lib/backend/thi-session-handler.js | 2 +- rogue-thi-app/pages/login.jsx | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6d357ed2..fda250ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,8 @@ RUN curl --output-dir data/ https://assets.neuland.app/generated/ical-courses.js RUN npm run build +ENV NODE_ENV=production + USER node EXPOSE 3000 CMD ["npm", "start"] diff --git a/assets/spo-parser/run.sh b/assets/spo-parser/run.sh index 74d57b9d..51d81f0e 100644 --- a/assets/spo-parser/run.sh +++ b/assets/spo-parser/run.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ -n "$NEXT_PUBLIC_GUEST_ONLY" ]; then +if [ "$NEXT_PUBLIC_GUEST_ONLY" = "true" ]; then echo "Skipping grade weight extraction (guest only mode)" echo "{}" > spo-grade-weights.json exit 0 diff --git a/rogue-thi-app/lib/backend/thi-session-handler.js b/rogue-thi-app/lib/backend/thi-session-handler.js index a99bb8ed..40b92fd2 100644 --- a/rogue-thi-app/lib/backend/thi-session-handler.js +++ b/rogue-thi-app/lib/backend/thi-session-handler.js @@ -73,7 +73,7 @@ export async function callWithSession(method) { // redirect user if he never had a session if (!session) { throw new NoSessionError() - } else if (session === 'guest2' || process.env.NEXT_PUBLIC_GUEST_ONLY) { + } else if (session === 'guest2' || process.env.NEXT_PUBLIC_GUEST_ONLY === 'true') { throw new UnavailableSessionError() } diff --git a/rogue-thi-app/pages/login.jsx b/rogue-thi-app/pages/login.jsx index c1e35896..9420677c 100644 --- a/rogue-thi-app/pages/login.jsx +++ b/rogue-thi-app/pages/login.jsx @@ -24,7 +24,7 @@ const ORIGINAL_ERROR_WRONG_CREDENTIALS = 'Wrong credentials' const IMPRINT_URL = process.env.NEXT_PUBLIC_IMPRINT_URL const PRIVACY_URL = process.env.NEXT_PUBLIC_PRIVACY_URL const GIT_URL = process.env.NEXT_PUBLIC_GIT_URL -const GUEST_ONLY = !!process.env.NEXT_PUBLIC_GUEST_ONLY +const GUEST_ONLY = process.env.NEXT_PUBLIC_GUEST_ONLY === 'true' const KNOWN_BACKEND_ERRORS = ['Response is not valid JSON']