From db7f4c84bfd5cf4786ab761f8e56aaa28e476ce4 Mon Sep 17 00:00:00 2001 From: Umputun Date: Fri, 11 May 2018 16:10:11 -0500 Subject: [PATCH] prevent user from voting for they own comments --- app/store/service.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/store/service.go b/app/store/service.go index d2ed9fb9..72a9e0fd 100644 --- a/app/store/service.go +++ b/app/store/service.go @@ -58,6 +58,10 @@ func (s *Service) Vote(locator Locator, commentID string, userID string, val boo return comment, err } + if comment.User.ID == userID { + return comment, errors.Errorf("user %s can not vote for his own comment %s", userID, commentID) + } + if comment.Votes == nil { comment.Votes = make(map[string]bool) }