身份验证失败,Uploadify +回形针 +清除

发布于 2024-10-05 22:45:39 字数 687 浏览 0 评论 0原文

我的 Uploadify 几乎与 Paperclip 和身份验证一起使用,主要使用 本指南

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

有谁知道为什么会这样吗?

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

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

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

任何帮助将不胜感激,这对我来说有点太多了!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌面超妹 2024-10-12 22:45:39

我不知道这是否是你的问题,但我遇到了类似的问题,我设置了 2 个身份验证级别,一个具有基本的 http,一个具有设计,该会话对于设计和所有内容都运行良好,但从未绕过基本的http...
希望这有帮助。

亚历克斯

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

椒妓 2024-10-12 22:45:39

将会话密钥和值传递给 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/

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文