gitlab-org--gitlab-foss/app/policies/group_member_policy.rb
2016-08-30 11:39:22 -07:00

19 lines
415 B
Ruby

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
end
end