Commit 6d76e000 authored by miks's avatar miks

Add authorization to hooks requests

parent 2e34a6d3
...@@ -113,6 +113,7 @@ module Gitlab ...@@ -113,6 +113,7 @@ module Gitlab
# Example Request: # Example Request:
# GET /projects/:id/hooks # GET /projects/:id/hooks
get ":id/hooks" do get ":id/hooks" do
authorize! :admin_project, user_project
@hooks = paginate user_project.hooks @hooks = paginate user_project.hooks
present @hooks, with: Entities::Hook present @hooks, with: Entities::Hook
end end
...@@ -125,6 +126,7 @@ module Gitlab ...@@ -125,6 +126,7 @@ module Gitlab
# Example Request: # Example Request:
# POST /projects/:id/hooks # POST /projects/:id/hooks
post ":id/hooks" do post ":id/hooks" do
authorize! :admin_project, user_project
@hook = user_project.hooks.new({"url" => params[:url]}) @hook = user_project.hooks.new({"url" => params[:url]})
if @hook.save if @hook.save
present @hook, with: Entities::Hook present @hook, with: Entities::Hook
...@@ -141,6 +143,7 @@ module Gitlab ...@@ -141,6 +143,7 @@ module Gitlab
# Example Request: # Example Request:
# DELETE /projects/:id/hooks # DELETE /projects/:id/hooks
delete ":id/hooks" do delete ":id/hooks" do
authorize! :admin_project, user_project
@hook = user_project.hooks.find(params[:hook_id]) @hook = user_project.hooks.find(params[:hook_id])
@hook.destroy @hook.destroy
nil nil
......
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