Commit b32a8eea authored by Valeriy Sizov's avatar Valeriy Sizov

API: MergeRequest: authorization

parent 524b9070
...@@ -6,12 +6,18 @@ module Gitlab ...@@ -6,12 +6,18 @@ module Gitlab
resource :projects do resource :projects do
#list #list
get ":id/merge_requests" do get ":id/merge_requests" do
authorize! :read_merge_request, user_project
present user_project.merge_requests, with: Entities::MergeRequest present user_project.merge_requests, with: Entities::MergeRequest
end end
#show #show
get ":id/merge_request/:merge_request_id" do get ":id/merge_request/:merge_request_id" do
present user_project.merge_requests.find(params[:merge_request_id]), with: Entities::MergeRequest merge_request = user_project.merge_requests.find(params[:merge_request_id])
authorize! :read_merge_request, merge_request
present merge_request, with: Entities::MergeRequest
end end
#create merge_request #create merge_request
...@@ -20,6 +26,8 @@ module Gitlab ...@@ -20,6 +26,8 @@ module Gitlab
merge_request = user_project.merge_requests.new(attrs) merge_request = user_project.merge_requests.new(attrs)
merge_request.author = current_user merge_request.author = current_user
authorize! :write_merge_request, merge_request
if merge_request.save if merge_request.save
merge_request.reload_code merge_request.reload_code
present merge_request, with: Entities::MergeRequest present merge_request, with: Entities::MergeRequest
...@@ -33,6 +41,8 @@ module Gitlab ...@@ -33,6 +41,8 @@ module Gitlab
attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :closed] attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :closed]
merge_request = user_project.merge_requests.find(params[:merge_request_id]) merge_request = user_project.merge_requests.find(params[:merge_request_id])
authorize! :modify_merge_request, merge_request
if merge_request.update_attributes attrs if merge_request.update_attributes attrs
merge_request.reload_code merge_request.reload_code
merge_request.mark_as_unchecked merge_request.mark_as_unchecked
......
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