BigW Consortium Gitlab

project_member_policy.rb 488 Bytes
Newer Older
1
class ProjectMemberPolicy < BasePolicy
2
  delegate { @subject.project }
3

4 5
  condition(:target_is_owner, scope: :subject) { @subject.user == @subject.project.owner }
  condition(:target_is_self) { @user && @subject.user == @user }
6

7 8
  rule { anonymous }.prevent_all
  rule { target_is_owner }.prevent_all
9

10 11 12
  rule { can?(:admin_project_member) }.policy do
    enable :update_project_member
    enable :destroy_project_member
13
  end
14 15

  rule { target_is_self }.enable :destroy_project_member
16
end