debian-mirror-gitlab/lib/gitlab/auth/result.rb
2019-12-04 20:38:33 +05:30

28 lines
628 B
Ruby

# frozen_string_literal: true
module Gitlab
module Auth
Result = Struct.new(:actor, :project, :type, :authentication_abilities) do
prepend_if_ee('::EE::Gitlab::Auth::Result') # rubocop: disable Cop/InjectEnterpriseEditionModule
def ci?(for_project)
type == :ci &&
project &&
project == for_project
end
def lfs_deploy_token?(for_project)
type == :lfs_deploy_token &&
actor.try(:has_access_to?, for_project)
end
def success?
actor.present? || type == :ci
end
def failed?
!success?
end
end
end
end