小编use*_*385的帖子

Rails中可能出现HTTP基本自定义错误?

我正在使用Ruby 1.8.7在Rails 2.3.14中构建一个应用程序.

我的客户在网络研讨会页面上请求了一个非常简单的身份验证.我认为使用http_auth非常合适,因为它只需要一个非常基本的用户名和密码.

现在,她要求如果他们点击取消或使用错误的信息,他们会被重定向到一个基本上说"如果你忘记了登录信息,请联系我们"的页面.

当我们得到"HTTP Basic:Access denied"时,我该如何做到这一点.错误,我可以改为重定向到一个页面?或者,只需使用我们的自定义样式/内容自定义此页面?

提前致谢.

这是我的网络研讨会控制器的代码:

class WebinarsController < ApplicationController
before_filter :authenticate, :only => [:bpr]

def bpr
 render :action => :bpr
end

protected 
def authenticate
  authenticate_or_request_with_http_basic do |username, password|
    username == "abc" && password == "123"
  end
end

end
Run Code Online (Sandbox Code Playgroud)

ruby authentication ruby-on-rails basic-authentication

4
推荐指数
1
解决办法
1681
查看次数