2018-09-23 19:44:14 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-15 16:31:14 +00:00
|
|
|
class Import::GiteaController < Import::GithubController
|
|
|
|
def new
|
2016-12-16 16:43:34 +00:00
|
|
|
if session[access_token_key].present? && session[host_key].present?
|
2016-12-15 16:31:14 +00:00
|
|
|
redirect_to status_import_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def personal_access_token
|
2016-12-16 16:43:34 +00:00
|
|
|
session[host_key] = params[host_key]
|
2016-12-15 16:31:14 +00:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def status
|
2016-12-16 16:43:34 +00:00
|
|
|
@gitea_host_url = session[host_key]
|
2016-12-15 16:31:14 +00:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-12-16 16:43:34 +00:00
|
|
|
def host_key
|
|
|
|
:"#{provider}_host_url"
|
|
|
|
end
|
|
|
|
|
2018-10-30 10:53:01 +00:00
|
|
|
# Overridden methods
|
2016-12-15 16:31:14 +00:00
|
|
|
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 16:43:34 +00:00
|
|
|
if session[access_token_key].blank? || session[host_key].blank?
|
2016-12-15 16:31:14 +00: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 16:43:34 +00:00
|
|
|
{ host: session[host_key], api_version: 'v1' }
|
2016-12-15 16:31:14 +00:00
|
|
|
end
|
|
|
|
end
|