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

22 lines
681 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
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 }
2020-07-28 23:09:34 +05:30
condition(:project_bot) { @subject.user&.project_bot? }
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
2020-07-28 23:09:34 +05:30
rule { ~project_bot & can?(:admin_project_member) }.policy do
2017-09-10 17:25:29 +05:30
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
2020-07-28 23:09:34 +05:30
rule { project_bot & can?(:admin_project_member) }.enable :destroy_project_bot_member
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