我一整天都在尝试通过简单的get来验证身份。

class ApiController < ApplicationController
  def signin
    warden.authenticate(params[:email], params[:password])
    render :json => current_user.to_json
  end
end

当我用http://localhost:3000/api/signin?email=theemailaddress&password=thepassword
我收到消息:“邮件地址策略无效”,下面是堆栈:
warden (1.0.4) lib/warden/proxy.rb:323:in `_fetch_strategy'
warden (1.0.4) lib/warden/proxy.rb:307:in `block in _run_strategies_for'
warden (1.0.4) lib/warden/proxy.rb:306:in `each'
warden (1.0.4) lib/warden/proxy.rb:306:in `_run_strategies_for'
warden (1.0.4) lib/warden/proxy.rb:279:in `_perform_authentication'
warden (1.0.4) lib/warden/proxy.rb:90:in `authenticate'
actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:5:in `send_action'

我需要什么才能让这样的事情继续下去?

最佳答案

您需要定义一个自定义的典狱长策略并检查请求头。看看什么I did here

关于ruby-on-rails - 设计和认证,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6240501/

10-10 03:45