Search code examples
authenticationdeviserubymotion

Ruby Motion, Rails 3.x, Devise login through custom api/v1/sessions_controller.rb


I'm using this lucatironi tutorial to do my RM/rails/devise native authentication. I got everything working except one piece where I authenticate in the sessions_controller.rb

I'm sending in

{ session : { email: "test@five.com", password: "password" } } (bubblewrap is forcing a 'sessions' node onto my JSON!)

resource_name is :api_v1_user

controller_path is "api/v1/sessions"

class Api::V1::SessionsController < Devise::SessionsController
  def create
   warden.authenticate!(:scope => resource_name, :store => false, :recall => "#{controller_path}#failure")
   render :status => 200,
       :json => { :success => true,
                  :info => "Logged in",
                  :data => { :auth_token => current_user.authentication_token } }
  end
end

All I get is an alert in the app "Login Failed"

Thanks for any help


Solution

  • So I figured this out.

    authenticate! doesn't return annything

    has to be "authenticate" with no "!"

    that was it!