BigW Consortium Gitlab

Commit 26628fb9 by Valery Sizov

BB importer: Fixed bug with putting expired token to a project.clone_url

parent 076cdd20
......@@ -49,6 +49,9 @@ class Import::BitbucketController < Import::BaseController
namespace = find_or_create_namespace(@target_namespace, current_user)
if current_user.can?(:create_projects, namespace)
# The token in a session can be expired, we need to get most recent one because
# Bitbucket::Connection class refreshes it.
session[:bitbucket_token] = bitbucket_client.connection.token
@project = Gitlab::BitbucketImport::ProjectCreator.new(repo, @project_name, namespace, current_user, credentials).execute
else
render 'unauthorized'
......
module Bitbucket
class Client
attr_reader :connection
def initialize(options = {})
@connection = Connection.new(options)
end
......@@ -48,8 +50,6 @@ module Bitbucket
private
attr_reader :connection
def get_collection(path, type)
paginator = Paginator.new(connection, path, type)
Collection.new(paginator)
......
......@@ -4,6 +4,8 @@ module Bitbucket
DEFAULT_BASE_URI = 'https://api.bitbucket.org/'
DEFAULT_QUERY = {}
attr_reader :expires_at, :expires_in, :refresh_token, :token
def initialize(options = {})
@api_version = options.fetch(:api_version, DEFAULT_API_VERSION)
@base_uri = options.fetch(:base_uri, DEFAULT_BASE_URI)
......@@ -38,8 +40,6 @@ module Bitbucket
private
attr_reader :expires_at, :expires_in, :refresh_token, :token
def client
@client ||= OAuth2::Client.new(provider.app_id, provider.app_secret, options)
end
......
......@@ -21,7 +21,7 @@ module Gitlab
visibility_level: repo.visibility_level,
import_type: 'bitbucket',
import_source: repo.full_name,
import_url: repo.clone_url(@session_data[:token]),
import_url: repo.clone_url(session_data[:token]),
import_data: { credentials: session_data }
).execute
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment