Skip to content

fix: support optional auth for quiz joining #158 - #228

Merged
TheCodeHeist-Coder merged 1 commit into
TheCodeHeist-Coder:mainfrom
SubhadeepAtta:fix/optional-auth-quiz-join
Oct 29, 2026
Merged

TheCodeHeist-Coder merged 1 commit into
TheCodeHeist-Coder:mainfrom
SubhadeepAtta:fix/optional-auth-quiz-join

Conversation

@SubhadeepAtta

@SubhadeepAtta SubhadeepAtta commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds optional authentication to the quiz joining endpoint (POST /join).

  • Allows participants to join quizzes without providing an authentication token.
  • Associates authenticated participants with their user ID when a valid JWT is provided.
  • Handles invalid, malformed, or expired JWTs gracefully by allowing the participant to join anonymously.
  • Preserves the existing anonymous quiz-joining flow.

Related issue

Related to #158 (already fixed in 6f104cd) — this tightens the type guard
in optionalAuthMiddleware.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactoring
  • Performance
  • Tests
  • Build / CI / deployment

Which services does this touch?

  • apps/frontend
  • apps/http-server
  • apps/ws-server
  • apps/genAI
  • packages/db (schema or Prisma changes)
  • Docker / CI

How did you test this?

  • Ran pnpm --filter http-server dev; TypeScript compilation completed and the server started on port 4000.
  • The server reported a missing ApiRequestLog database table during request-log flushing.
  • Postman testing of anonymous, valid-token, and invalid-token scenarios has not yet been completed.

Checklist

  • I ran pnpm run lint
  • I ran pnpm --filter http-server check-types
  • I ran pnpm run build
  • The app still starts with docker-compose up
  • I updated documentation if this changes behaviour or setup
  • I did not commit any .env file, API key or other secret

@SubhadeepAtta SubhadeepAtta changed the title fix: support optional auth for quiz joining fix: support optional auth for quiz joining #158 Oct 29, 2026
@TheCodeHeist-Coder
TheCodeHeist-Coder self-requested a review October 29, 2026 06:03
@TheCodeHeist-Coder

Copy link
Copy Markdown
Owner

Merging this for the type guard — the

typeof decoded.userId === "string" && decoded.userId.length > 0

check is stricter than what was there and matches organizerAuth.ts in
ws-server, so it's worth having.

One thing for next time: #158 was already fixed in 6f104cd, so
optionalAuthMiddleware already existed and was already wired to POST /join.
Worth pulling latest main and checking the code before starting on an issue
— saves you the work.

If you want something more substantial, that middleware has no test coverage
at all. Tests for it would be genuinely useful: no header, malformed header,
valid token, expired token, token with no userId claim. http-server has
vitest set up now.

@TheCodeHeist-Coder
TheCodeHeist-Coder merged commit f79d95a into TheCodeHeist-Coder:main Oct 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants