summaryrefslogtreecommitdiff
path: root/app/controllers/import/gitlab_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/import/gitlab_controller.rb')
-rw-r--r--app/controllers/import/gitlab_controller.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/controllers/import/gitlab_controller.rb b/app/controllers/import/gitlab_controller.rb
index 08130ee8176..73837ffbe67 100644
--- a/app/controllers/import/gitlab_controller.rb
+++ b/app/controllers/import/gitlab_controller.rb
@@ -26,15 +26,14 @@ class Import::GitlabController < Import::BaseController
def create
@repo_id = params[:repo_id].to_i
repo = client.project(@repo_id)
- @project_name = repo["name"]
+ @project_name = repo['name']
+ @target_namespace = find_or_create_namespace(repo['namespace']['path'], client.user['username'])
- repo_owner = repo["namespace"]["path"]
- repo_owner = current_user.username if repo_owner == client.user["username"]
- @target_namespace = params[:new_namespace].presence || repo_owner
-
- namespace = get_or_create_namespace || (render and return)
-
- @project = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, current_user, access_params).execute
+ if current_user.can?(:create_projects, @target_namespace)
+ @project = Gitlab::GitlabImport::ProjectCreator.new(repo, @target_namespace, current_user, access_params).execute
+ else
+ render 'unauthorized'
+ end
end
private