debian-mirror-gitlab/app/policies/group_member_policy.rb

27 lines
626 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
class GroupMemberPolicy < BasePolicy
2017-09-10 17:25:29 +05:30
delegate :group
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
with_scope :subject
condition(:last_owner) { @subject.group.last_owner?(@subject.user) }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
desc "Membership is users' own"
with_score 0
condition(:is_target_user) { @user && @subject.user_id == @user.id }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
rule { anonymous }.prevent_all
rule { last_owner }.prevent_all
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
rule { can?(:admin_group_member) }.policy do
enable :update_group_member
enable :destroy_group_member
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
rule { is_target_user }.policy do
enable :destroy_group_member
2016-09-29 09:46:39 +05:30
end
end
2019-12-16 22:33:55 +05:30
GroupMemberPolicy.prepend_if_ee('EE::GroupMemberPolicy')