API: Use #find_project in API::Triggers and API::Services

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2016-11-24 13:22:38 +01:00
parent 4d2e7894ef
commit 304163becb
No known key found for this signature in database
GPG key ID: 46DF07E5CD9E96AB
2 changed files with 2 additions and 2 deletions

View file

@ -65,7 +65,7 @@ module API
detail 'Added in GitLab 8.13'
end
post ':id/services/:service_slug/trigger' do
project = Project.find_with_namespace(params[:id]) || Project.find_by(id: params[:id])
project = find_project(params[:id])
# This is not accurate, but done to prevent leakage of the project names
not_found!('Service') unless project

View file

@ -13,7 +13,7 @@ module API
optional :variables, type: Hash, desc: 'The list of variables to be injected into build'
end
post ":id/(ref/:ref/)trigger/builds" do
project = Project.find_with_namespace(params[:id]) || Project.find_by(id: params[:id])
project = find_project(params[:id])
trigger = Ci::Trigger.find_by_token(params[:token].to_s)
not_found! unless project && trigger
unauthorized! unless trigger.project == project