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

34 lines
822 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
2021-04-17 20:07:23 +05:30
condition(:last_owner) { @subject.group.last_owner?(@subject.user) || @subject.group.last_blocked_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
2021-03-08 18:12:59 +05:30
rule { anonymous }.policy do
prevent :update_group_member
prevent :destroy_group_member
end
2021-01-29 00:20:46 +05:30
rule { last_owner }.policy do
prevent :update_group_member
prevent :destroy_group_member
end
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-04 20:38:33 +05:30
GroupMemberPolicy.prepend_if_ee('EE::GroupMemberPolicy')