如何防止浏览器HTTP身份验证对话框出现w / Devise和jQuery Mobile(How to Prevent Browser HTTP Authentication Dialog from

编程入门 行业动态 更新时间:2024-10-27 21:16:10
如何防止浏览器HTTP身份验证对话框出现w / Devise和jQuery Mobile(How to Prevent Browser HTTP Authentication Dialog from Appearing w/Devise and jQuery Mobile)

我正在尝试将Devise身份验证和jQuery Mobile用于Rails 3项目。 我已经将数据角色的东西添加到我的设计视图中,我可以做一些事情,比如注册新用户而没有任何问题。 事实上,只要我正确输入电子邮件和密码,我就可以毫无问题地登录。 如果我输错了,浏览器会抛出一个HTTP身份验证对话框。 我的config \ initializers \ devise.rb文件已经包含:

Devise.setup do |config| config.http_authenticatable = false config.http_authenticatable_on_xhr = false config.navigational_formats = [:html, :js] end

我知道这与使用AJAX提交表单并返回401响应的jQuery Mobile有关,但我不知道我需要做什么才能让它像普通页面一样,只需用闪存重新渲染它信息。

我是AJAX和jQuery的新手,所以答案中的细节越多越好。

谢谢!

I'm trying to use Devise authentication and jQuery Mobile for a Rails 3 project. I've added the data-role stuff to my devise views and I can do things like register a new user without any problems. In fact, I can sign in without any problems as long as I correctly type the email and password. If I type something wrong the browser throws up an HTTP authentication dialog box. My config\initializers\devise.rb file already contains:

Devise.setup do |config| config.http_authenticatable = false config.http_authenticatable_on_xhr = false config.navigational_formats = [:html, :js] end

I know this has something to do with jQuery Mobile using AJAX to submit the form and returning a 401 response, but I have no idea what I need to do to make it behave like a normal page where it just re-renders it with the flash message.

I'm totally new to AJAX and jQuery so the more details in an answer the better.

Thanks!

最满意答案

好吧,我想我终于搞清楚了。 我在我的application.mobile.erb文件中有j1移动CSS和JS文件的a1版本,我需要在我的iPhone上关闭浏览器以清除缓存。 无论如何,我认为这就解决了这个问题。 现在似乎工作正常。

Well, I think I finally figured this out. I had the a1 versions of jQuery Mobile CSS and JS files in my application.mobile.erb file AND I needed to shut down my browser on my iPhone to clear the cache. Anyway, I think that is what resolved the problem. It seems to be working fine now.

更多推荐

本文发布于:2023-08-04 16:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1417915.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   身份验证   如何防止   浏览器   Devise

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!