gitlab-org--gitlab-foss/app/policies/group_member_policy.rb
gfyoung d5bf57a6af Enable frozen string in presenters and policies
Enable frozen string in:

* app/presenters
* app/policies

Partially addresses #47424.
2018-07-24 13:18:25 -07:00

24 lines
568 B
Ruby

# frozen_string_literal: true
class GroupMemberPolicy < BasePolicy
delegate :group
with_scope :subject
condition(:last_owner) { @subject.group.last_owner?(@subject.user) }
desc "Membership is users' own"
with_score 0
condition(:is_target_user) { @user && @subject.user_id == @user.id }
rule { anonymous }.prevent_all
rule { last_owner }.prevent_all
rule { can?(:admin_group_member) }.policy do
enable :update_group_member
enable :destroy_group_member
end
rule { is_target_user }.policy do
enable :destroy_group_member
end
end