John H
John H

Reputation: 2488

Authentication fails with Uploadify + Paperclip + Clearance

I have Uploadify almost working with Paperclip and Authentication, mostly using this guide.

I've got past the nasty InvalidAuthenticationToken errors by passing the Authentication_token and session information as parameters and using middleware to create a cookie header from them, however the controller authentication filter is still failing and the current_user is not available.

Has anyone any ideas as to why this might be?

I looked through the Clearance plugin and it seems to come down to the user_from_cookie method, which finds the user based on cookies[:remember_token]

  def user_from_cookie
    if token = cookies[:remember_token]
      ::User.find_by_remember_token(token)
    end
  end

So i'm thinking the middleware should also create a remember_token cookie header?

Any help would be appreciated, this is proving a bit much for me!

Upvotes: 0

Views: 280

Answers (2)

Vignesh
Vignesh

Reputation: 131

Passing the session key and value to your rails app should retrieve the session data using with authentication is done.

uploadify_script_data[csrf_param] = encodeURI(csrf_token);
uploadify_script_data[app["session_key"]] = app["session_val"];

$("#upload").uploadify({
      "swf" : "/swf/uploadify.swf",
      "uploader" : "/upload/document.json",
      "formData" : uploadify_script_data,
      "buttonText" : "Upload file",
      "method" : "post",
      "removeCompleted": true,
      "multi" : false,
      "auto" : true,
      "fileTypeDesc" : "Image",
      "fileSizeLimit" : "1000kb"
    }); 

For a detailed tutorial look at http://vignesh.info/blog/rails-4-uploadify-paperclip/

Upvotes: 0

Alex
Alex

Reputation: 4507

I don't know if this is your issue, but I run into a similar one, I had setup 2 auth level, one with basic http and one with devise, the session worked beautifully for devise and all, but never got around the basic http... Hope this helps.

Alex

Upvotes: 0

Related Questions