diff options
Diffstat (limited to 'app/policies/group_member_policy.rb')
-rw-r--r-- | app/policies/group_member_policy.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/policies/group_member_policy.rb b/app/policies/group_member_policy.rb index a394b63fc8e..f61f758a8e8 100644 --- a/app/policies/group_member_policy.rb +++ b/app/policies/group_member_policy.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class GroupMemberPolicy < BasePolicy + include MemberPolicyHelpers + delegate :group with_scope :subject @@ -9,7 +11,11 @@ class GroupMemberPolicy < BasePolicy desc "Membership is users' own" with_score 0 - condition(:is_target_user) { @user && @subject.user_id == @user.id } + condition(:target_is_self) { record_belongs_to_self? } + + desc "Membership is users' own access request" + with_score 0 + condition(:access_request_of_self) { record_is_access_request_of_self? } rule { anonymous }.policy do prevent :update_group_member @@ -28,9 +34,13 @@ class GroupMemberPolicy < BasePolicy rule { project_bot & can?(:admin_group_member) }.enable :destroy_project_bot_member - rule { is_target_user }.policy do + rule { target_is_self }.policy do enable :destroy_group_member end + + rule { access_request_of_self }.policy do + enable :withdraw_member_access_request + end end GroupMemberPolicy.prepend_mod_with('GroupMemberPolicy') |