Commit 8ac50d78 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Check project existence for push too, and

we don't have to check for deploy key for downloading
because deploy key could certainly download when it
could already read the project.

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7383#note_19578626
parent 57e3e942
...@@ -9,8 +9,6 @@ module Gitlab ...@@ -9,8 +9,6 @@ module Gitlab
download: 'You are not allowed to download code from this project.', download: 'You are not allowed to download code from this project.',
deploy_key_upload: deploy_key_upload:
'This deploy key does not have write access to this project.', 'This deploy key does not have write access to this project.',
deploy_key:
'This deploy key does not have access to this project.',
no_repo: 'A repository for this project does not exist yet.' no_repo: 'A repository for this project does not exist yet.'
} }
...@@ -33,10 +31,11 @@ module Gitlab ...@@ -33,10 +31,11 @@ module Gitlab
check_active_user! unless deploy_key? check_active_user! unless deploy_key?
check_project_accessibility! check_project_accessibility!
check_command_existence!(cmd) check_command_existence!(cmd)
check_repository_existence!
case cmd case cmd
when *DOWNLOAD_COMMANDS when *DOWNLOAD_COMMANDS
download_access_check download_access_check unless deploy_key?
when *PUSH_COMMANDS when *PUSH_COMMANDS
push_access_check(changes) push_access_check(changes)
end end
...@@ -47,20 +46,12 @@ module Gitlab ...@@ -47,20 +46,12 @@ module Gitlab
end end
def download_access_check def download_access_check
passed = if deploy_key passed = user_can_download_code? ||
deploy_key.has_access_to?(project) build_can_download_code? ||
elsif user guest_can_download_code?
user_can_download_code? || build_can_download_code?
end || guest_can_download_code?
unless passed unless passed
message = if deploy_key raise UnauthorizedError, ERROR_MESSAGES[:download]
ERROR_MESSAGES[:deploy_key]
else
ERROR_MESSAGES[:download]
end
raise UnauthorizedError, message
end end
end end
...@@ -75,7 +66,6 @@ module Gitlab ...@@ -75,7 +66,6 @@ module Gitlab
return if changes.blank? # Allow access. return if changes.blank? # Allow access.
check_repository_existence!
check_change_access!(changes) check_change_access!(changes)
end end
......
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