2018-10-11 20:12:21 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
2016-09-19 11:42:10 +00:00
|
|
|
module Auth
|
2016-09-19 12:23:18 +00:00
|
|
|
Result = Struct.new(:actor, :project, :type, :authentication_abilities) do
|
2016-09-20 08:24:47 +00:00
|
|
|
def ci?(for_project)
|
|
|
|
type == :ci &&
|
|
|
|
project &&
|
|
|
|
project == for_project
|
2016-09-19 11:42:10 +00:00
|
|
|
end
|
|
|
|
|
2016-09-20 08:24:47 +00:00
|
|
|
def lfs_deploy_token?(for_project)
|
|
|
|
type == :lfs_deploy_token &&
|
2016-11-16 12:31:08 +00:00
|
|
|
actor.try(:has_access_to?, for_project)
|
2016-09-19 14:34:32 +00:00
|
|
|
end
|
|
|
|
|
2016-09-19 11:42:10 +00:00
|
|
|
def success?
|
|
|
|
actor.present? || type == :ci
|
|
|
|
end
|
2017-05-31 13:55:12 +00:00
|
|
|
|
|
|
|
def failed?
|
|
|
|
!success?
|
|
|
|
end
|
2016-09-19 11:42:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|