OSDN Git Service

Per project protection
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Fri, 15 Feb 2013 07:51:21 +0000 (09:51 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Fri, 15 Feb 2013 07:51:21 +0000 (09:51 +0200)
app/controllers/files_controller.rb

index 09f1e55..3cd2e77 100644 (file)
@@ -1,7 +1,13 @@
 class FilesController < ApplicationController
   def download
-    uploader = Note.find(params[:id]).attachment
-    send_file uploader.file.path, disposition: 'attachment'
+    note = Note.find(params[:id])
+
+    if can?(current_user, :read_project, note.project)
+      uploader = note.attachment
+      send_file uploader.file.path, disposition: 'attachment'
+    else
+      not_found!
+    end
   end
 end