Commit 795acf2e authored by Kamil Trzcinski's avatar Kamil Trzcinski

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

parent 242e77e0
......@@ -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?
......
......@@ -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?
......
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?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment