Problem
The project has multiple voting endpoints with different validation behavior.
Older vote routes check reputation before voting, while newer /upvote and /downvote routes do not enforce the same checks.
Additionally, one route attempts to call:
on an ObjectId instead of a populated user document.
Files Involved
server/routes/questions.js
server/controllers/answersController.js
Current Behavior
- Some vote endpoints allow low-reputation users to vote
- Some routes may fail during reputation updates
- Voting behavior differs across APIs
Expected Behavior
All voting endpoints should:
- enforce the same authorization rules
- validate voting permissions consistently
- safely update reputation
- return consistent responses
Steps To Reproduce
- Use a low-reputation account
- Call newer
/upvote or /downvote endpoints
- Observe that voting succeeds without proper checks
Root Cause
Voting logic is duplicated across multiple routes/controllers and not centralized.
Some routes use populated user handling while others directly use ObjectIds.
Proposed Fix
- Create shared vote helper/controller logic
- Enforce
req.user.canVote() consistently
- Fetch/populate content authors before reputation updates
- Optionally prevent self-voting
I am selected as a GSSoC contributor and would like to work on this issue. Please assign it to me.
Problem
The project has multiple voting endpoints with different validation behavior.
Older vote routes check reputation before voting, while newer
/upvoteand/downvoteroutes do not enforce the same checks.Additionally, one route attempts to call:
on an ObjectId instead of a populated user document.
Files Involved
server/routes/questions.jsserver/controllers/answersController.jsCurrent Behavior
Expected Behavior
All voting endpoints should:
Steps To Reproduce
/upvoteor/downvoteendpointsRoot Cause
Voting logic is duplicated across multiple routes/controllers and not centralized.
Some routes use populated user handling while others directly use ObjectIds.
Proposed Fix
req.user.canVote()consistentlyI am selected as a GSSoC contributor and would like to work on this issue. Please assign it to me.