我正在使用authenticate_or_request_with_http_basic进行身份验证。我想将用户重定向到联系表单,如果他们仍然无法登录,那么他们可以在尝试几次后与我联系。
class MySiteController < ApplicationController
before_filter :authenticate
def index
end
protected
def authenticate
count = 0
authenticate = authenticate_or_request_with_http_basic do |username, password|
username == 'username' && password == 'password'
count += 1
if count == 3
break
end
end
if authenticate == false
redirect_to contact_path
end
end
end