Commit d1f72816e963a4810014dbdd0ce8d4037245c3b9
1 parent
6b78cf93
Exists in
master
and in
27 other branches
invite-controller: simplify permission check
Showing
4 changed files
with
13 additions
and
5 deletions
Show diff stats
app/controllers/public/invite_controller.rb
... | ... | @@ -85,10 +85,6 @@ class InviteController < PublicController |
85 | 85 | protected |
86 | 86 | |
87 | 87 | def check_permissions_to_invite |
88 | - if profile.person? and !user.has_permission?(:manage_friends, profile) or | |
89 | - profile.community? and !user.has_permission?(:invite_members, profile) | |
90 | - render_access_denied | |
91 | - end | |
88 | + render_access_denied if !profile.allow_invitation_from?(user) | |
92 | 89 | end |
93 | - | |
94 | 90 | end | ... | ... |
app/models/organization.rb
... | ... | @@ -177,4 +177,8 @@ class Organization < Profile |
177 | 177 | self.visible = false |
178 | 178 | save! |
179 | 179 | end |
180 | + | |
181 | + def allow_invitation_from?(person) | |
182 | + (followed_by?(person) && self.allow_members_to_invite) || person.has_permission?('invite-members', self) | |
183 | + end | |
180 | 184 | end | ... | ... |
app/models/person.rb