Proposal/teacher onboarding mvp - #595
Merged
utsab merged 18 commits intoSep 15, 2026
Merged
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
utsab
requested changes
Jun 16, 2026
Collaborator
There was a problem hiding this comment.
Overall, this PR is a solid end-to-end workflow for the teacher invite. Nice work.
Can you add some tests? Given that there are so many status change branches (pending, accepted, rejected, expired), it would be good to have a test that verifies that each status is assigned correctly. You can mock the 3rd party apps (like the SMTP server).
You may also want to add a test to confirm that an uninvited teacher cannot access the classes page.
2 tasks
…cceptance page, tests)
…ity signature
- Convert pages/error.js and pages/teacher/invite/[inviteToken].js to modern Next.js Link pattern (no nested anchors)
- Refactor util/inviteEmail.js to accept object params {invitedTeacherEmail, inviteUrl, expiresAt, invitedByEmail}
- Ensures proper Nodemailer integration for teacher invitation emails
- redesign invite acceptance page with FCC-aligned styling - update teacher invitation email content and branding hierarchy - fix teacher invite post-accept redirect by role - improve revoke API message for inactive invites - add README testing/setup notes for SMTP invite flow
…tion The StudentInvitation model/relations were leftover scaffolding from an earlier, superseded student-invite design and had no consumers anywhere in this branch (student onboarding shipped via a different, join-link based flow in freeCodeCamp#600). Per review feedback, they don't belong in the teacher invitation PR. Also collapsed the two migrations back into a single initial_setup migration, regenerated via `prisma migrate dev` against a local dev database, since the project is still pre-release and doesn't need incremental migration history yet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
signIn('auth0') skipped NextAuth's provider selection and always
launched Auth0's flow, even for contributors running locally with
GITHUB_OAUTH_PROVIDER_ENABLED=true and no Auth0 credentials. Switch to
signIn(null, { callbackUrl }), matching the provider-agnostic pattern
already used in components/authButton.js, and keep the user on the
invite-accept page after sign-in instead of redirecting to '/'.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds tests for pages/api/teacher_invites/accept.js,
pages/api/admin/teacher_invites/{resend,revoke}.js covering each status
branch (PENDING valid/expired, already ACCEPTED by self/other, and
REVOKED/CANCELLED/EXPIRED rejection), per review feedback asking for
coverage of each invitation status. Prisma, next-auth's session lookup,
and outbound email are all mocked - no real database or SMTP calls.
Also documents current role-promotion behavior on accept: ADMIN is
protected and stays ADMIN, while TEACHER/STUDENT/NONE are all
unconditionally promoted to TEACHER (single-role field, no student
guard needed since classroom membership is just a roster entry).
Adds direct unit tests for areEquivalentInviteEmails' Gmail-style
email normalization (dot/plus stripping), previously untested.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CarlyAThomas
force-pushed
the
proposal/teacher-onboarding-mvp
branch
from
September 3, 2026 00:21
fca2eec to
a80a4c4
Compare
pages/classes/index.js's getServerSideProps gate only checks a user's current role - it has no notion of invitation history. That single check is what covers every way an account can lack teacher access: never invited, a teacher invite that was revoked or left to expire before being accepted, or being demoted/removed after previously being a teacher. Covers that gate: no session and non-TEACHER role both redirect to /error, ADMIN redirects to /admin, and only an accepted TEACHER reaches the page. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
Author
|
I added test coverage for both asks:
All mocked (Prisma, session, email) — no real DB/SMTP in the test run. Hi @utsab it's ready for a re-review when you are available! |
utsab
approved these changes
Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist:
Update index.md)This PR is not associated with a specific issue
Case Study (Teacher Invite Acceptance Flow)
/teacher/invite/<token>.ACCEPTEDand user role is set toTEACHER.What Changed (and Why)
Teacher invite backend APIs to support create/list/resend/revoke and secure acceptance.
Reason: completes the core onboarding lifecycle with role-safe state transitions.
Files:
pages/api/admin/teacher_invites/create.js
pages/api/admin/teacher_invites/list.js
pages/api/admin/teacher_invites/resend.js
pages/api/admin/teacher_invites/revoke.js
pages/api/teacher_invites/accept.js
util/inviteApiUtils.js
Email delivery + feature flag rollout support.
Reason: enables controlled rollout and real invitation delivery.
Files:
util/inviteEmail.js
util/featureFlags.js
package.json
package-lock.json
Admin + teacher UI flow.
Reason: gives a usable end-to-end path from invite creation to invite acceptance.
Files:
components/TeacherInvitesPanel.js
components/TeacherInvitesPanel.module.css
pages/admin/index.js
pages/teacher/invite/[inviteToken].js
styles/Home.module.css
pages/error.js
Data model + migration for invitation lifecycle.
Reason: persists invitation state and supports expiry/revoke/accept transitions.
Files:
prisma/schema.prisma
prisma/migrations/20260409192210_add_invitation_models/migration.sql
Env/security/docs updates.
Reason: prevent future secret leaks and keep setup clear with tracked templates.
Files:
.gitignore
.env.sample
.env.development.example
.env.production.example
README.md
.env.development/.env.productionremoved from trackingValidation
npm run lint:codenpm testHow to Test
Prerequisites
This branch allows you to create an
ADMINaccount and send out email invitations to users to onboard as teachers.You need:
Configuring this branch for local development
CarlyAThomas:proposal/teacher-onboarding-mvpbranch.cp .env.development.example .env.developmentSMTP_USERin.env.developmentwith your Admin Email.SMTP_PASSin.env.developmentwith the new password.Running the app
npx prisma migrate reset, and pressyto reset your database.npm run developandnpx prisma studioto run the project.ADMIN.Testing