diff options
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index d35ec73c8c1..5284d1d2305 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -199,18 +199,21 @@ module API post 'fork/:id' do attrs = {} namespace_id = params[:namespace] + if namespace_id.present? namespace = Namespace.find_by(id: namespace_id) || Namespace.find_by_path_or_name(namespace_id) - if namespace.nil? - not_found!('Target Namespace') - end + + not_found!('Target Namespace') unless namespace authorize! :create_projects, namespace + attrs[:namespace] = namespace end + @forked_project = ::Projects::ForkService.new(user_project, current_user, attrs).execute + if @forked_project.errors.any? conflict!(@forked_project.errors.messages) else |