enhance: ensure that only assessment course participants can access assessment live quizzes#4911
Conversation
…ssessment live quizzes
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds EDUID login scope (Prisma enum + migration), sets participant JWT scope to Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as Participant Browser
participant PWA as PWA /session/[id].tsx (SSR)
participant Auth as Cookies
participant GQL as GraphQL API
participant Svc as LiveQuizzes Service
User->>PWA: GET /session/:id
PWA->>Auth: Read cookie next-auth.participant-session-token
Note right of PWA: If present, add Authorization: Bearer <token>
PWA->>GQL: Query GetRunningLiveQuiz (with/without Bearer)
GQL->>Svc: getRunningLiveQuiz()
alt Assessment quiz
Svc->>Svc: Check user role=PARTICIPANT & scope=EDUID
alt Missing/invalid
Svc-->>GQL: Error UNAUTHORIZED_ASSESSMENT (FORBIDDEN)
GQL-->>PWA: GraphQL error
PWA-->>User: Redirect to APP_ORIGIN_ASSESSMENT_PWA login?redirect_to=<current>
else Has courseId
Svc->>Svc: Verify course participation (Prisma)
alt Not a participant
Svc-->>GQL: Error MISSING_ASSESSMENT_COURSE_PARTICIPATION
GQL-->>PWA: GraphQL error
PWA-->>User: Redirect to APP_ORIGIN_ASSESSMENT_PWA?error=missing_assessment_course_participation
else Participant ok
Svc-->>GQL: Quiz data
GQL-->>PWA: Quiz data
PWA->>PWA: Enforce host APP_ORIGIN_ASSESSMENT_PWA
PWA-->>User: Redirect if host mismatch else render
end
end
else Non-assessment quiz
Svc-->>GQL: Quiz data
GQL-->>PWA: Quiz data
PWA->>PWA: Enforce host APP_ORIGIN_PWA
PWA-->>User: Redirect if host mismatch else render
end
sequenceDiagram
autonumber
actor User as Participant Browser
participant PWAHome as PWA /
Note over PWAHome: On mount
User->>PWAHome: Navigate with ?error=missing_assessment_course_participation
PWAHome->>PWAHome: Show toast t('pwa.assessment.missingAssessmentCourseParticipation') for 7000ms
PWAHome->>PWAHome: router.replace (remove error, shallow)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (11)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|


Summary by CodeRabbit