diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-29 00:10:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-29 00:10:45 +0300 |
commit | 71d6b9014bef64436bbd996667e6458ebde561c4 (patch) | |
tree | 21b049d24b2d96be84904576e2b619f82d5d515d /app/policies/group_member_policy.rb | |
parent | 0076bbc67375ff1507e42ce479406daf92c0a6a2 (diff) |
Add latest changes from gitlab-org/gitlab@master
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') |