使用Uploadify + Paperclip + Clearance进行身份验证失败

时间:2010-12-02 23:26:23

标签: ruby-on-rails paperclip uploadify clearance

我上传几乎使用Paperclip和身份验证,主要使用this guide

我已经通过将Authentication_token和会话信息作为参数传递并使用中间件从它们创建cookie头来解决了令人讨厌的InvalidAuthenticationToken错误,但是控制器身份验证过滤器仍然失败并且current_user不可用。

有没有人想过为什么会这样?

我查看了Clearance插件,它似乎归结为user_from_cookie方法,该方法根据cookie找到用户[:remember_token]

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

所以我认为中间件也应该创建一个remember_token cookie标头?

任何帮助都会受到赞赏,这对我来说有点多了!

2 个答案:

答案 0 :(得分:0)

我不知道这是不是你的问题,但是我遇到了类似的问题,我设置了2个auth级别,一个用基本的http和一个用devise,会话工作得非常漂亮,但是从来没有围绕基本的http ... 希望这会有所帮助。

亚历

答案 1 :(得分:0)

将会话密钥和值传递给rails应用程序应该使用身份验证来检索会话数据。

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"
    }); 

有关详细教程,请查看http://vignesh.info/blog/rails-4-uploadify-paperclip/