大家好我authenticate_or_request_with_http_basic
有问题,这是代码:
def authenticate
puts "here 1"
if authenticate_or_request_with_http_basic('Qontak') do |username, password|
puts "here 2"
@user = User.find_by(public_key: username, private_key: password)
end
else
puts "here 3"
render json: {message: 'Unauthorized'}
end
puts "here 4"
end
当我调试更新方法时,控制台打印出来:
here 1
here 4
然后有这样的错误日志:
Filter chain halted as :authenticate rendered or redirected
Completed 401 Unauthorized in 19ms (ActiveRecord: 2.2ms)
之后我被重定向到show route
并且控制台成功打印了这个
here 1
here 2
here 4
我想知道身份验证时put/patch/update
方法发生了什么?为什么它失败但没有显示/获取路线?