开发者

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!


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


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜