2018-09-23 15:44:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-15 11:31:14 -05:00
|
|
|
class Import::GiteaController < Import::GithubController
|
|
|
|
def new
|
2016-12-16 11:43:34 -05:00
|
|
|
if session[access_token_key].present? && session[host_key].present?
|
2016-12-15 11:31:14 -05:00
|
|
|
redirect_to status_import_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def personal_access_token
|
2016-12-16 11:43:34 -05:00
|
|
|
session[host_key] = params[host_key]
|
2016-12-15 11:31:14 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def status
|
2016-12-16 11:43:34 -05:00
|
|
|
@gitea_host_url = session[host_key]
|
2016-12-15 11:31:14 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-12-16 11:43:34 -05:00
|
|
|
def host_key
|
|
|
|
:"#{provider}_host_url"
|
|
|
|
end
|
|
|
|
|
2016-12-15 11:31:14 -05:00
|
|
|
# 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
|
2016-12-16 11:43:34 -05:00
|
|
|
if session[access_token_key].blank? || session[host_key].blank?
|
2016-12-15 11:31:14 -05:00
|
|
|
redirect_to new_import_gitea_url,
|
|
|
|
alert: 'You need to specify both an Access Token and a Host URL.'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def client_options
|
2016-12-16 11:43:34 -05:00
|
|
|
{ host: session[host_key], api_version: 'v1' }
|
2016-12-15 11:31:14 -05:00
|
|
|
end
|
|
|
|
end
|