Move logic to check ci? or lfs_deploy_token? to Gitlab::Auth::Result

This commit is contained in:
Kamil Trzcinski 2016-09-20 10:24:47 +02:00
parent 242e77e070
commit 795acf2e4e
3 changed files with 12 additions and 12 deletions

View File

@ -127,15 +127,11 @@ class Projects::GitHttpClientController < Projects::ApplicationController
end
def ci?
authentication_result.ci? &&
authentication_project &&
authentication_project == project
authentication_result.ci?(project)
end
def lfs_deploy_key?
authentication_result.lfs_deploy_token? &&
actor &&
actor.projects.include?(project)
def lfs_deploy_token?
authentication_result.lfs_deploy_token?(project)
end
def authentication_has_download_access?

View File

@ -25,7 +25,7 @@ module LfsHelper
def lfs_download_access?
return false unless project.lfs_enabled?
project.public? || ci? || lfs_deploy_key? || user_can_download_code? || build_can_download_code?
project.public? || ci? || lfs_deploy_token? || user_can_download_code? || build_can_download_code?
end
def user_can_download_code?

View File

@ -1,12 +1,16 @@
module Gitlab
module Auth
Result = Struct.new(:actor, :project, :type, :authentication_abilities) do
def ci?
type == :ci
def ci?(for_project)
type == :ci &&
project &&
project == for_project
end
def lfs_deploy_token?
type == :lfs_deploy_token
def lfs_deploy_token?(for_project)
type == :lfs_deploy_token &&
actor &&
actor.projects.include?(for_project)
end
def success?