You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the contribution!
The implementation is clean, covers the required edge cases, and includes solid test coverage.
Really appreciate the attention to security and overall reliability.
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
ECSoC26-L3Difficult, auto-assigned by Sentinel — 15 pointsECSoC26Required label for a PR to be eligible for Sentinel scoringgood-backendPA-awarded bonus for outstanding backend work — +50 XPgood-prPA-awarded bonus for an exceptionally executed PR — +15 XP
2 participants
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.
Description
Restricts teacher course deletion to courses owned by the authenticated teacher while preserving admin access to delete any course.
Fixes #40
ECSoC26
This contribution is submitted under ECSoC26.
Problem
The course deletion route was protected by authentication and role middleware, but the controller deleted courses using only the supplied course ID.
A teacher who knew another course ID could therefore attempt to delete a course owned by a different teacher.
Implementation
Authenticated ownership
Ownership is derived only from the verified authentication context:
or:
The controller does not trust
req.body.userId.Teacher access
Teachers may delete only courses whose stored
userIdmatches their authenticated user ID.The actual deletion query remains ownership-scoped:
Admin access
Admins may delete any course using:
Controlled errors
The controller now returns:
400for malformed MongoDB course IDs403when a teacher does not own the course404when the course does not exist500for unexpected database or server failuresLocal video cleanup
After successful database deletion, referenced local videos are removed safely.
The cleanup utility:
Tests
Added tests for:
Acceptance criteria
400404Verification
Tests
Result:
Syntax checks
Relevant code checks
Test evidence