2016-08-18 12:52:35 -04:00
|
|
|
class GroupMemberPolicy < BasePolicy
|
|
|
|
def rules
|
|
|
|
return unless @user
|
|
|
|
|
|
|
|
target_user = @subject.user
|
|
|
|
group = @subject.group
|
|
|
|
|
|
|
|
return if group.last_owner?(target_user)
|
|
|
|
|
|
|
|
can_manage = Ability.allowed?(@user, :admin_group_member, group)
|
|
|
|
|
|
|
|
if can_manage
|
|
|
|
can! :update_group_member
|
|
|
|
can! :destroy_group_member
|
|
|
|
elsif @user == target_user
|
|
|
|
can! :destroy_group_member
|
|
|
|
end
|
2016-12-13 08:51:09 -05:00
|
|
|
|
|
|
|
additional_rules!
|
|
|
|
end
|
|
|
|
|
|
|
|
def additional_rules!
|
|
|
|
# This is meant to be overriden in EE
|
2016-08-18 12:52:35 -04:00
|
|
|
end
|
|
|
|
end
|