diff options
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/helpers/internal_helpers.rb | 14 | ||||
-rw-r--r-- | lib/api/internal.rb | 15 |
2 files changed, 13 insertions, 16 deletions
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb index bff245fe9a2..fdb441375eb 100644 --- a/lib/api/helpers/internal_helpers.rb +++ b/lib/api/helpers/internal_helpers.rb @@ -66,16 +66,18 @@ module API false end - def project_namespace - strong_memoize(:project_namespace) do - project&.namespace || Namespace.find_by_full_path(project_match[:namespace_path]) - end + def project_path + project&.path || project_path_match[:project_path] + end + + def namespace_path + project&.namespace&.path || project_path_match[:namespace_path] end private - def project_match - @project_match ||= params[:project].match(Gitlab::PathRegex.full_project_git_path_regex) || {} + def project_path_match + @project_path_match ||= params[:project].match(Gitlab::PathRegex.full_project_git_path_regex) || {} end # rubocop:disable Gitlab/ModuleWithInstanceVariables diff --git a/lib/api/internal.rb b/lib/api/internal.rb index ed6d022df97..9285fb90cdc 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -42,23 +42,18 @@ module API end access_checker_klass = wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess - access_checker = access_checker_klass - .new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities, redirected_path: redirected_path, target_namespace: project_namespace) + access_checker = access_checker_klass.new(actor, project, + protocol, authentication_abilities: ssh_authentication_abilities, + namespace_path: namespace_path, project_path: project_path, + redirected_path: redirected_path) begin access_checker.check(params[:action], params[:changes]) + @project ||= access_checker.project rescue Gitlab::GitAccess::UnauthorizedError, Gitlab::GitAccess::NotFoundError => e return { status: false, message: e.message } end - if receive_pack? && project.blank? - begin - @project = ::Projects::CreateFromPushService.new(user, project_match[:project_path], project_namespace, protocol).execute - rescue Gitlab::GitAccess::ProjectCreationError => e - return { status: false, message: e.message } - end - end - log_user_activity(actor) { |