Merge pull request #2754 from evazion/fix-comment-selfvotes

Prevent users from upvoting their own comments.
This commit is contained in:
Albert Yi
2016-11-11 16:46:50 -08:00
committed by GitHub
2 changed files with 17 additions and 5 deletions

View File

@@ -36,7 +36,10 @@ class CommentVote < ActiveRecord::Base
end
def validate_comment_can_be_down_voted
if is_negative? && comment.creator.is_admin?
if is_positive? && comment.creator == CurrentUser.user
errors.add :base, "You cannot upvote your own comments"
false
elsif is_negative? && comment.creator.is_admin?
errors.add :base, "You cannot downvote an admin comment"
false
else