diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /app/policies/project_member_policy.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'app/policies/project_member_policy.rb')
-rw-r--r-- | app/policies/project_member_policy.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/policies/project_member_policy.rb b/app/policies/project_member_policy.rb index 40ba30fce5e..bcfc7c87d41 100644 --- a/app/policies/project_member_policy.rb +++ b/app/policies/project_member_policy.rb @@ -1,13 +1,18 @@ # frozen_string_literal: true class ProjectMemberPolicy < BasePolicy + include MemberPolicyHelpers delegate { @subject.project } condition(:target_is_holder_of_the_personal_namespace, scope: :subject) do @subject.project.personal_namespace_holder?(@subject.user) end - condition(:target_is_self) { @user && @subject.user == @user } + desc "Membership is users' own access request" + with_score 0 + condition(:access_request_of_self) { record_is_access_request_of_self? } + + condition(:target_is_self) { record_belongs_to_self? } condition(:project_bot) { @subject.user&.project_bot? } rule { anonymous }.prevent_all @@ -24,5 +29,11 @@ class ProjectMemberPolicy < BasePolicy rule { project_bot & can?(:admin_project_member) }.enable :destroy_project_bot_member - rule { target_is_self }.enable :destroy_project_member + rule { target_is_self }.policy do + enable :destroy_project_member + end + + rule { access_request_of_self }.policy do + enable :withdraw_member_access_request + end end |