SECURITY: verify that inviter can invite new user to a topic

This commit is contained in:
Arpit Jalan
2017-10-09 15:52:41 +05:30
parent 59aeb0bc56
commit a2183c3f1d
4 changed files with 25 additions and 2 deletions

View File

@ -138,7 +138,7 @@ class Invite < ActiveRecord::Base
invite.invited_groups.create!(group_id: group_id)
end
else
if topic && topic.category # && Guardian.new(invited_by).can_invite_to?(topic)
if topic && topic.category && Guardian.new(invited_by).can_invite_to?(topic)
group_ids = topic.category.groups.pluck(:id) - invite.invited_groups.pluck(:group_id)
group_ids.each { |group_id| invite.invited_groups.create!(group_id: group_id) }
end