Commit 64d7772b authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use a separate method to skip validation

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8091#note_20222666
parent 4bf59f87
...@@ -41,7 +41,7 @@ module Ci ...@@ -41,7 +41,7 @@ module Ci
put ":id" do put ":id" do
authenticate_runner! authenticate_runner!
build = Ci::Build.where(runner_id: current_runner.id).running.find(params[:id]) build = Ci::Build.where(runner_id: current_runner.id).running.find(params[:id])
authenticate_build!(build, verify_token: false) validate_build!(build)
update_runner_info update_runner_info
......
...@@ -13,9 +13,14 @@ module Ci ...@@ -13,9 +13,14 @@ module Ci
forbidden! unless current_runner forbidden! unless current_runner
end end
def authenticate_build!(build, verify_token: true) def authenticate_build!(build)
not_found! unless build
forbidden! if !build_token_valid?(build)
validate_build!(build)
end
def validate_build!(build)
not_found! unless build not_found! unless build
forbidden! if verify_token && !build_token_valid?(build)
forbidden!('Project has been deleted!') unless build.project forbidden!('Project has been deleted!') unless build.project
forbidden!('Build has been erased!') if build.erased? forbidden!('Build has been erased!') if build.erased?
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment