Skip to content

fix(routes): add auth to GET /tasks and GET /messages, remove duplicate registrations [NSoC'26]#163

Open
anshul23102 wants to merge 1 commit into
Shriii19:masterfrom
anshul23102:fix/158-get-routes-require-auth
Open

fix(routes): add auth to GET /tasks and GET /messages, remove duplicate registrations [NSoC'26]#163
anshul23102 wants to merge 1 commit into
Shriii19:masterfrom
anshul23102:fix/158-get-routes-require-auth

Conversation

@anshul23102
Copy link
Copy Markdown

Description

Fixes two related route-registration bugs in tasks.routes.js and chat.routes.js.

Issue #158: Unauthenticated read access

GET /api/tasks and GET /api/messages were registered without authenticateUser. 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 /:id appeared twice in tasks.routes.js once with authenticateUser and once without. If registration order were ever changed, unauthenticated deletion would become the active path.

Changes Made

File Change
backend/routes/tasks.routes.js Added authenticateUser to router.get("/"). Removed all duplicate route registrations. Each route now has one registration with the correct middleware chain.
backend/routes/chat.routes.js Added authenticateUser to router.get("/"). Removed duplicate router.post("/") registration.

Testing Done

  • GET /api/tasks without a Bearer token returns 401.
  • GET /api/messages without a Bearer token returns 401.
  • POST /api/tasks, PATCH, and DELETE still require authentication.
  • All mutation routes apply both authenticateUser and the relevant validation middleware.

Checklist

  • No merge conflicts with master
  • No em dashes or double hyphens in comments
  • Changes focused on the reported surfaces
  • This PR is linked to the correct issues

Closes #158
Closes #159

…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
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

@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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

👋 Thank you for opening this pull request! I will review your changes and assist you soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant