diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /lib/gitlab/git_access_wiki.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'lib/gitlab/git_access_wiki.rb')
-rw-r--r-- | lib/gitlab/git_access_wiki.rb | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/lib/gitlab/git_access_wiki.rb b/lib/gitlab/git_access_wiki.rb index aad46937c32..a941282e713 100644 --- a/lib/gitlab/git_access_wiki.rb +++ b/lib/gitlab/git_access_wiki.rb @@ -2,41 +2,50 @@ module Gitlab class GitAccessWiki < GitAccess - prepend_if_ee('EE::Gitlab::GitAccessWiki') # rubocop: disable Cop/InjectEnterpriseEditionModule + extend ::Gitlab::Utils::Override ERROR_MESSAGES = { - read_only: "You can't push code to a read-only GitLab instance.", + download: 'You are not allowed to download files from this wiki.', + not_found: 'The wiki you were looking for could not be found.', + no_repo: 'A repository for this wiki does not exist yet.', + read_only: "You can't push code to a read-only GitLab instance.", write_to_wiki: "You are not allowed to write to this project's wiki." }.freeze - def guest_can_download_code? - Guest.can?(:download_wiki_code, project) + override :download_ability + def download_ability + :download_wiki_code end - def user_can_download_code? - authentication_abilities.include?(:download_code) && user_access.can_do_action?(:download_wiki_code) + override :push_ability + def push_ability + :create_wiki end + override :check_change_access! def check_change_access! - unless user_access.can_do_action?(:create_wiki) - raise ForbiddenError, ERROR_MESSAGES[:write_to_wiki] - end - - if Gitlab::Database.read_only? - raise ForbiddenError, push_to_read_only_message - end + raise ForbiddenError, write_to_wiki_message unless user_can_push? true end def push_to_read_only_message - ERROR_MESSAGES[:read_only] + error_message(:read_only) end - private + def write_to_wiki_message + error_message(:write_to_wiki) + end + def not_found_message + error_message(:not_found) + end + + override :repository def repository - project.wiki.repository + container.wiki.repository end end end + +Gitlab::GitAccessWiki.prepend_if_ee('EE::Gitlab::GitAccessWiki') |