summaryrefslogtreecommitdiff
path: root/lib/api/internal/base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/internal/base.rb')
-rw-r--r--lib/api/internal/base.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb
index f1e33b27d2b..0d50a310b37 100644
--- a/lib/api/internal/base.rb
+++ b/lib/api/internal/base.rb
@@ -43,12 +43,9 @@ module API
Gitlab::Git::HookEnv.set(gl_repository, env) if container
actor.update_last_used_at!
- access_checker = access_checker_for(actor, params[:protocol])
check_result = begin
- result = access_checker.check(params[:action], params[:changes])
- @project ||= access_checker.project
- result
+ access_check!(actor, params)
rescue Gitlab::GitAccess::ForbiddenError => e
# The return code needs to be 401. If we return 403
# the custom message we return won't be shown to the user
@@ -92,6 +89,17 @@ module API
response_with_status(code: 500, success: false, message: UNKNOWN_CHECK_RESULT_ERROR)
end
end
+
+ def access_check!(actor, params)
+ access_checker = access_checker_for(actor, params[:protocol])
+ access_checker.check(params[:action], params[:changes]).tap do |result|
+ break result if @project || !repo_type.project?
+
+ # If we have created a project directly from a git push
+ # we have to assign its value to both @project and @container
+ @project = @container = access_checker.project
+ end
+ end
end
namespace 'internal' do