设计和认证
我一整天都在尝试通过简单的获取来进行身份验证。
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
我收到消息:“无效策略 theemailaddress”,这是堆栈:
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've been trying all day to get a way to authenticate via a simple get.
class ApiController < ApplicationController
def signin
warden.authenticate(params[:email], params[:password])
render :json => current_user.to_json
end
end
When I hit this with something like http://localhost:3000/api/signin?email=theemailaddress&password=thepassword
I get the message: "Invalid strategy theemailaddress", here is the stack:
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'
What do I need to get something like this going?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要定义自定义 Warden 策略并检查请求标头。看看我在这里做了什么。
You need to define a custom warden strategy and check the request headers. Look at what I did here.