summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-12-20 03:24:38 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-12-20 03:24:38 +0800
commit18c9fc42249a08ff28cf9d5b9159b7bada168bcf (patch)
tree0192fc7ed6a5302be252ceccf8028591b7ccb3c3
parenta0690c4c01fceccef9efca70a9256f5790fba9c7 (diff)
downloadgitlab-ce-fix-forbidden-for-build-api-for-deleted-project.tar.gz
Use a block to insert extra check for authenticate_build!fix-forbidden-for-build-api-for-deleted-project
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8091#note_20253762
-rw-r--r--lib/ci/api/helpers.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/ci/api/helpers.rb b/lib/ci/api/helpers.rb
index 62c10c3b753..31fbd1da108 100644
--- a/lib/ci/api/helpers.rb
+++ b/lib/ci/api/helpers.rb
@@ -14,13 +14,16 @@ module Ci
end
def authenticate_build!(build)
- not_found! unless build
- forbidden! unless build_token_valid?(build)
- validate_build!(build)
+ validate_build!(build) do
+ forbidden! unless build_token_valid?(build)
+ end
end
def validate_build!(build)
not_found! unless build
+
+ yield if block_given?
+
forbidden!('Project has been deleted!') unless build.project
forbidden!('Build has been erased!') if build.erased?
end