Permissions handling#54
Open
OrigamiStarz wants to merge 24 commits intomainfrom
Open
Conversation
|
Visit the preview URL for this PR (updated for commit b8809bb): https://meemli-dev--pr54-permissions-handling-rqcyq9k8.web.app (expires Wed, 13 May 2026 02:42:39 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 633a893569aee98f762f025e27aa080a469727e1 |
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.
Summary
Resolves #37
Implements Role-Based Access Control (RBAC) across the backend API and frontend UI, scoping
what admins vs. teachers can see and do.
Link to permissions doc: Google Doc
Changes
Backend
New middleware
attachUserContext.ts— fetches the authenticated user's MongoDB document after tokenverification and attaches it to
req.userContextfor downstream userequireAdmin.ts— reusable middleware that short-circuits non-admin requests with a 403permissions.ts— shared helpers (hasStudentAccess,hasSectionAccess,TEACHER_EDITABLE_STUDENT_FIELDS,TEACHER_STUDENT_PROJECTION) for consistent permissionchecks across controllers
app.ts— wiredattachUserContextinto all/api/*route groupsControllers updated
comments,preassessmentScore,postassessmentScore)Frontend
isAdminfromAuthContextAdminRoutecomponent guards admin-only pagesNavbarhides admin-only links for non-admin usersenrolledSectionsfor teachers)StudentStaffPage,StudentEditForm,StudentTabs,SectionCard,StudentCardallupdated to respect role context
Testing
Confirmation of Change
Admin
Screen.Recording.2026-05-05.at.2.08.42.AM.mov
Non-Admin
Screen.Recording.2026-05-05.at.2.32.18.AM.mov
Screen.Recording.2026-05-05.at.2.36.32.AM.mov