FIX: must be able to post in a topic in order to vote on a poll

This commit is contained in:
Régis Hanol
2018-02-27 00:19:44 +01:00
parent fd33090646
commit dee35b72f2
2 changed files with 20 additions and 0 deletions

View File

@ -47,6 +47,11 @@ after_initialize do
raise StandardError.new I18n.t("poll.topic_must_be_open_to_vote")
end
# user must be allowed to post in topic
unless Guardian.new(user).can_create_post?(post.topic)
raise StandardError.new I18n.t("poll.user_cant_post_in_topic")
end
polls = post.custom_fields[DiscoursePoll::POLLS_CUSTOM_FIELD]
raise StandardError.new I18n.t("poll.no_polls_associated_with_this_post") if polls.blank?