Steven
Steven

Reputation: 4963

devise and authentication

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?

Upvotes: 2

Views: 2010

Answers (1)

David
David

Reputation: 7303

You need to define a custom warden strategy and check the request headers. Look at what I did here.

Upvotes: 2

Related Questions