summaryrefslogtreecommitdiff
path: root/app/controllers/import/github_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/import/github_controller.rb')
-rw-r--r--app/controllers/import/github_controller.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb
index b9f99c1b88a..f21fbd9ecca 100644
--- a/app/controllers/import/github_controller.rb
+++ b/app/controllers/import/github_controller.rb
@@ -5,9 +5,7 @@ class Import::GithubController < Import::BaseController
rescue_from Octokit::Unauthorized, with: :github_unauthorized
def callback
- token = client.get_token(params[:code])
- current_user.github_access_token = token
- current_user.save
+ session[:github_access_token] = client.get_token(params[:code])
redirect_to status_import_github_url
end
@@ -39,13 +37,13 @@ class Import::GithubController < Import::BaseController
namespace = get_or_create_namespace || (render and return)
- @project = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, current_user).execute
+ @project = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, current_user, access_params).execute
end
private
def client
- @client ||= Gitlab::GithubImport::Client.new(current_user.github_access_token)
+ @client ||= Gitlab::GithubImport::Client.new(session[:github_access_token])
end
def verify_github_import_enabled
@@ -53,7 +51,7 @@ class Import::GithubController < Import::BaseController
end
def github_auth
- if current_user.github_access_token.blank?
+ if session[:github_access_token].blank?
go_to_github_for_permissions
end
end
@@ -65,4 +63,10 @@ class Import::GithubController < Import::BaseController
def github_unauthorized
go_to_github_for_permissions
end
+
+ private
+
+ def access_params
+ { github_access_token: session[:github_access_token] }
+ end
end