mongodb - How to use Devise authorization in custom middleware -
i have middleware serving files mongodb
#serve_gridfs_file.rb class servegridfsfile def initialize(app) @app = app end def call(env) if env["path_info"] =~ /^\/grid\/(.+)$/ process_request(env, $1.force_encoding("utf-8")) else @app.call(env) end end private def process_request(env, key) begin mongo::gridfilesystem.new(mongoid.database).open(key, 'r') |file| [200, { 'content-type' => file.content_type }, [file.read]] end rescue [404, { 'content-type' => 'text/plain' }, ['file not found.']] end end end
i use devise capabilities current_user. after that, use validation. not know how in simple manner.
Comments
Post a Comment