git_access_wiki.rb 599 Bytes
Newer Older
1 2
module Gitlab
  class GitAccessWiki < GitAccess
Michael Kozono's avatar
Michael Kozono committed
3 4 5 6
    ERROR_MESSAGES = {
      write_to_wiki: "You are not allowed to write to this project's wiki."
    }.freeze

7
    def guest_can_download_code?
8 9 10 11 12 13 14
      Guest.can?(:download_wiki_code, project)
    end

    def user_can_download_code?
      authentication_abilities.include?(:download_code) && user_access.can_do_action?(:download_wiki_code)
    end

15
    def check_single_change_access(change)
16
      unless user_access.can_do_action?(:create_wiki)
17
        raise UnauthorizedError, ERROR_MESSAGES[:write_to_wiki]
18
      end
19 20

      true
21 22 23
    end
  end
end