如果身份验证失败,我正在尝试重定向到root_path。 目前,它只是通过HTTP Basic更改页面主体:拒绝访问。
这是我的控制器:
class ProjectsController < ApplicationController
before_filter :http_basic_auth, only: [:show]
def http_basic_auth
if (authenticate_or_request_with_http_basic do |user, password| password == @project.passcode && user == @project.passcode end if @project.private?)
true
else
response.headers["Location"] = url_for(root_path)
end
end
end
研究了以下内容,但我仍然无法做到正确:
Rails: What is the location option for in the render method
答案 0 :(得分:1)
我仍然无法让这个工作:
尝试使用authenticate_or_request_with_http_basic
代替 if user = authenticate_with_http_basic { |u, p| @account.users.authenticate(u, p) }
@current_user = user
else
request_http_basic_authentication
end
android.provider.Telephony.SMS_RECEIVED