Skip to content

Commit

Permalink
Solved duplicate votes issue; Discovered karma exploitation
Browse files Browse the repository at this point in the history
Exploit - Currently even if you already upvoted you can click the upvote button again, which doesn't add a new vote to the post/comment but *does* add more to the user's karma since there's no check for existing vote value to only add karma for actual changes to votes
  • Loading branch information
extrajordanary committed Dec 20, 2014
1 parent 3d2e07a commit 7f3c740
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ def comment_params
end

def current_user_existing_vote
@vote = current_user.votes.find_by(comment_id: params[:id])
@vote = current_user.votes.find_by(votable_id: params[:id])
end
end
3 changes: 2 additions & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def correct_user
end

def current_user_existing_vote
@vote = current_user.votes.find_by(post_id: params[:id])
# @vote = current_user.votes.find_by(post_id: params[:id])
@vote = current_user.votes.find_by(votable_id: params[:id])
end
end

0 comments on commit 7f3c740

Please sign in to comment.