收录日期:2020/12/03 00:11:01 时间:2010-12-24 05:28:56 标签:ruby-on-rails,authentication,uploadify

I got uploadify to work properly with a model that I have without any authentication. The problem is, a user needs to be authenticated before s/he can upload a file. When I enable the before filter, the file doesn't get uploaded.

before_filter :authenticate

def authenticate
  authenticate_or_request_with_http_basic do |name, password|
    name == "foo" && password == "bar"
    true
  end
end

With this enabled. The upload fails. Here's what I see in my development log:

Filter chain halted as [:authenticate] rendered_or_redirected.
Completed in 2ms (View: 1, DB: 0) | 401 Unauthorized

This only happens with the flash upload, not with a regular for download.

Any ideas?

Thanks!

I've did this by taking off authentication for upload actions like this: "before_filter :authenticate, :except => [:swfupload]" Hope it helps.

Not much of an answer but I got around this by integrating session based authentication with authlogic instead. Don't love that solution but it works around the problem. Any ideas how to solve this specific problem would still be appreciated, though.