【发布时间】:2012-04-12 13:43:09
【问题描述】:
devise 使用before_filter :authenticate_user! 来限制只有经过身份验证的用户才能访问。
当未经身份验证的用户尝试访问受限页面时,devise 会自动导致重定向到登录页面。
因此尝试打开http://localhost:3000/users/edit 将导致重定向到http://localhost:3000/users/sign_in。
现在,如果我将链接 http://localhost:3000/users/edit 定义为 :remote => true,devise 只会通过 JS 发出 401 状态代码。
我怎样才能优雅地应对这种情况并在叠加层或重定向为非远程变体中显示登录对话框?
设计是否为我只需要激活的那种情况提供默认策略?
【问题讨论】:
标签: ruby-on-rails ajax authentication devise