BigW Consortium Gitlab

gitea_controller.rb 900 Bytes
Newer Older
1 2
class Import::GiteaController < Import::GithubController
  def new
3
    if session[access_token_key].present? && session[host_key].present?
4 5 6 7 8
      redirect_to status_import_url
    end
  end

  def personal_access_token
9
    session[host_key] = params[host_key]
10 11 12 13
    super
  end

  def status
14
    @gitea_host_url = session[host_key]
15 16 17 18 19
    super
  end

  private

20 21 22 23
  def host_key
    :"#{provider}_host_url"
  end

24 25 26 27 28 29 30 31 32 33 34 35
  # Overriden methods
  def provider
    :gitea
  end

  # Gitea is not yet an OAuth provider
  # See https://github.com/go-gitea/gitea/issues/27
  def logged_in_with_provider?
    false
  end

  def provider_auth
36
    if session[access_token_key].blank? || session[host_key].blank?
37 38 39 40 41 42
      redirect_to new_import_gitea_url,
        alert: 'You need to specify both an Access Token and a Host URL.'
    end
  end

  def client_options
43
    { host: session[host_key], api_version: 'v1' }
44 45
  end
end