gitlab-org--gitlab-foss/app/policies/ci/trigger_policy.rb
Fabio Pitino 42d99460d3 Allow use of legacy triggers with feature flag
Keep feature flag disabled by default and turn off
all functionality related to legacy triggers.

* Block legacy triggers from creating pipeline
* Highlight legacy triggers to be invalid via the UI
* Make legacy triggers invalid in the model
2019-07-15 15:05:22 +02:00

18 lines
496 B
Ruby

# frozen_string_literal: true
module Ci
class TriggerPolicy < BasePolicy
delegate { @subject.project }
with_options scope: :subject, score: 0
condition(:legacy) { @subject.supports_legacy_tokens? && @subject.legacy? }
with_score 0
condition(:is_owner) { @user && @subject.owner_id == @user.id }
rule { ~can?(:admin_build) }.prevent :admin_trigger
rule { legacy | is_owner }.enable :admin_trigger
rule { can?(:admin_build) }.enable :manage_trigger
end
end