fix(routes): add auth to GET /tasks and GET /messages, remove duplicate registrations [NSoC'26]#163
Open
anshul23102 wants to merge 1 commit into
Open
Conversation
…remove duplicate registrations [NSoC'26] GET /tasks and GET /messages were registered without any authentication middleware, exposing all project tasks and chat history to unauthenticated callers. Added authenticateUser to both GET endpoints. Also removed duplicate route registrations in both route files. POST /tasks, PATCH /:id, PATCH /:id/edit, and DELETE /:id were registered twice with conflicting middleware stacks. Express uses the first matched handler, making the second registrations dead code. The second DELETE /:id had no auth at all, which would allow unauthenticated deletion if the registration order was ever changed. Each route now has exactly one registration with the correct middleware chain: authenticateUser, then the relevant validation middleware, then the handler. Closes Shriii19#158 Closes Shriii19#159
|
@anshul23102 is attempting to deploy a commit to the shreemp194-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
👋 Thank you for opening this pull request! I will review your changes and assist you soon. |
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.
Description
Fixes two related route-registration bugs in
tasks.routes.jsandchat.routes.js.Issue #158: Unauthenticated read access
GET /api/tasksandGET /api/messageswere registered withoutauthenticateUser. Any unauthenticated HTTP client could retrieve the full task list and entire chat history of the workspace.Issue #159: Duplicate route registrations
Both route files registered mutation routes twice with conflicting middleware stacks. Express uses the first matched handler, making the second registrations dead code. Critically,
DELETE /:idappeared twice intasks.routes.jsonce withauthenticateUserand once without. If registration order were ever changed, unauthenticated deletion would become the active path.Changes Made
backend/routes/tasks.routes.jsauthenticateUsertorouter.get("/"). Removed all duplicate route registrations. Each route now has one registration with the correct middleware chain.backend/routes/chat.routes.jsauthenticateUsertorouter.get("/"). Removed duplicaterouter.post("/")registration.Testing Done
GET /api/taskswithout a Bearer token returns 401.GET /api/messageswithout a Bearer token returns 401.POST /api/tasks,PATCH, andDELETEstill require authentication.authenticateUserand the relevant validation middleware.Checklist
Closes #158
Closes #159