diff options
author | Robert Speicher <robert@gitlab.com> | 2016-11-28 05:33:35 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-11-28 05:33:35 +0000 |
commit | 8fad76b6ef47324d0b704af78c95cfe62fd7ba90 (patch) | |
tree | e5af44be0333df7c436bb1dd2f7cb4d38600c249 /app/helpers | |
parent | 3fc6eff5fce225610812cf3efdfcf8498a7b4144 (diff) | |
parent | 4b3c1e56ae7468d0234240dd211d54a7abd39f8f (diff) | |
download | gitlab-ce-8fad76b6ef47324d0b704af78c95cfe62fd7ba90.tar.gz |
Merge branch '22253-move-lfshelper-methods-somewhere-else-than-app-helpers' into 'master'
This moves methods from `LfsHelper` to a new `LfsRequest` concern and
introduces a new `WorkhorseRequest` concern.
Closes #22253
See merge request !7623
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/lfs_helper.rb | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/app/helpers/lfs_helper.rb b/app/helpers/lfs_helper.rb deleted file mode 100644 index 2425c3a8bc8..00000000000 --- a/app/helpers/lfs_helper.rb +++ /dev/null @@ -1,85 +0,0 @@ -module LfsHelper - include Gitlab::Routing.url_helpers - - def require_lfs_enabled! - return if Gitlab.config.lfs.enabled - - render( - json: { - message: 'Git LFS is not enabled on this GitLab server, contact your admin.', - documentation_url: help_url, - }, - status: 501 - ) - end - - def lfs_check_access! - return if download_request? && lfs_download_access? - return if upload_request? && lfs_upload_access? - - if project.public? || (user && user.can?(:read_project, project)) - render_lfs_forbidden - else - render_lfs_not_found - end - end - - def lfs_download_access? - return false unless project.lfs_enabled? - - ci? || lfs_deploy_token? || user_can_download_code? || build_can_download_code? - end - - def objects - @objects ||= (params[:objects] || []).to_a - end - - def user_can_download_code? - has_authentication_ability?(:download_code) && can?(user, :download_code, project) - end - - def build_can_download_code? - has_authentication_ability?(:build_download_code) && can?(user, :build_download_code, project) - end - - def lfs_upload_access? - return false unless project.lfs_enabled? - - has_authentication_ability?(:push_code) && can?(user, :push_code, project) - end - - def render_lfs_forbidden - render( - json: { - message: 'Access forbidden. Check your access level.', - documentation_url: help_url, - }, - content_type: "application/vnd.git-lfs+json", - status: 403 - ) - end - - def render_lfs_not_found - render( - json: { - message: 'Not found.', - documentation_url: help_url, - }, - content_type: "application/vnd.git-lfs+json", - status: 404 - ) - end - - def storage_project - @storage_project ||= begin - result = project - - loop do - break unless result.forked? - result = result.forked_from_project - end - - result - end - end -end |