diff options
author | Valeriy Sizov <vsv2711@gmail.com> | 2012-10-21 16:13:39 +0300 |
---|---|---|
committer | Valeriy Sizov <vsv2711@gmail.com> | 2012-10-22 23:09:21 +0300 |
commit | b32a8eea939930cd49141526b5fec19c747c561d (patch) | |
tree | a2ed287f4401ec8ff4a66d9480de1c96ca29077f /lib/api/merge_requests.rb | |
parent | 524b907042c36d832b82d980c9fee85e6d92b6da (diff) | |
download | gitlab-ce-b32a8eea939930cd49141526b5fec19c747c561d.tar.gz |
API: MergeRequest: authorization
Diffstat (limited to 'lib/api/merge_requests.rb')
-rw-r--r-- | lib/api/merge_requests.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index f1d8d6a9b55..14d9d92ae08 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -6,12 +6,18 @@ module Gitlab resource :projects do #list get ":id/merge_requests" do + authorize! :read_merge_request, user_project + present user_project.merge_requests, with: Entities::MergeRequest end #show 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 #create merge_request @@ -20,6 +26,8 @@ module Gitlab merge_request = user_project.merge_requests.new(attrs) merge_request.author = current_user + authorize! :write_merge_request, merge_request + if merge_request.save merge_request.reload_code present merge_request, with: Entities::MergeRequest @@ -33,6 +41,8 @@ module Gitlab attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :closed] merge_request = user_project.merge_requests.find(params[:merge_request_id]) + authorize! :modify_merge_request, merge_request + if merge_request.update_attributes attrs merge_request.reload_code merge_request.mark_as_unchecked |