blob: 78a2be7a9f861cfb7e9b73493bfedb752d80c8c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# 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 }.policy do
prevent :update_group_member
prevent :destroy_group_member
end
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
GroupMemberPolicy.prepend_if_ee('EE::GroupMemberPolicy')
|