diff --git a/app/controllers/public/invite_controller.rb b/app/controllers/public/invite_controller.rb index ff60041..94a11e9 100644 --- a/app/controllers/public/invite_controller.rb +++ b/app/controllers/public/invite_controller.rb @@ -85,10 +85,6 @@ class InviteController < PublicController protected def check_permissions_to_invite - if profile.person? and !user.has_permission?(:manage_friends, profile) or - profile.community? and !user.has_permission?(:invite_members, profile) - render_access_denied - end + render_access_denied if !profile.allow_invitation_from?(user) end - end diff --git a/app/models/organization.rb b/app/models/organization.rb index 2fea76d..a23340f 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -177,4 +177,8 @@ class Organization < Profile self.visible = false save! end + + def allow_invitation_from?(person) + (followed_by?(person) && self.allow_members_to_invite) || person.has_permission?('invite-members', self) + end end diff --git a/app/models/person.rb b/app/models/person.rb index 9a8310d..557ac24 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -514,6 +514,10 @@ class Person < Profile suggestion.disable if suggestion end + def allow_invitation_from?(person) + person.has_permission?(:manage_friends, self) + end + protected def followed_by?(profile) diff --git a/app/models/profile.rb b/app/models/profile.rb index 2f94881..c7cdfea 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -992,4 +992,8 @@ private :generate_url, :url_options suggestion.disable if suggestion end + def allow_invitation_from(person) + false + end + end -- libgit2 0.21.2