diff options
Diffstat (limited to 'app/controllers/import/gitea_controller.rb')
-rw-r--r-- | app/controllers/import/gitea_controller.rb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/app/controllers/import/gitea_controller.rb b/app/controllers/import/gitea_controller.rb index 4b4ac07b389..61e32650db3 100644 --- a/app/controllers/import/gitea_controller.rb +++ b/app/controllers/import/gitea_controller.rb @@ -16,12 +16,27 @@ class Import::GiteaController < Import::GithubController super end - # We need to re-expose controller's internal method 'status' as action. - # rubocop:disable Lint/UselessMethodDefinition def status - super + # Request repos to display error page if provider token is invalid + # Improving in https://gitlab.com/gitlab-org/gitlab/-/issues/25859 + client_repos + + respond_to do |format| + format.json do + render json: { imported_projects: serialized_imported_projects, + provider_repos: serialized_provider_repos, + incompatible_repos: serialized_incompatible_repos } + end + + format.html do + if params[:namespace_id].present? + @namespace = Namespace.find_by_id(params[:namespace_id]) + + render_404 unless current_user.can?(:create_projects, @namespace) + end + end + end end - # rubocop:enable Lint/UselessMethodDefinition protected @@ -61,7 +76,6 @@ class Import::GiteaController < Import::GithubController @client_repos ||= filtered(client.repos) end - override :client def client @client ||= Gitlab::LegacyGithubImport::Client.new(session[access_token_key], **client_options) end @@ -78,7 +92,7 @@ class Import::GiteaController < Import::GithubController provider_url, allow_localhost: allow_local_requests?, allow_local_network: allow_local_requests?, - schemes: %w(http https) + schemes: %w[http https] ) rescue Gitlab::UrlBlocker::BlockedUrlError => e session[access_token_key] = nil |