debian-mirror-gitlab/app/policies/project_member_policy.rb

17 lines
488 B
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
class ProjectMemberPolicy < BasePolicy
2017-09-10 17:25:29 +05:30
delegate { @subject.project }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
condition(:target_is_owner, scope: :subject) { @subject.user == @subject.project.owner }
condition(:target_is_self) { @user && @subject.user == @user }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
rule { anonymous }.prevent_all
rule { target_is_owner }.prevent_all
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
rule { can?(:admin_project_member) }.policy do
enable :update_project_member
enable :destroy_project_member
2016-09-29 09:46:39 +05:30
end
2017-09-10 17:25:29 +05:30
rule { target_is_self }.enable :destroy_project_member
2016-09-29 09:46:39 +05:30
end