This is my sessionController API above the devise SessionController
class Api::SessionsController < Devise::SessionsController
skip_before_filter :verify_authenticity_token,
:if => Proc.new { |c| c.request.format =='application/json' }
respond_to :json
def create
warden.authenticate!(:scope => resource_name, :recall => "Api::SessionsController#failure")
render :status => 200,
:json => { :success => true,
:info => "Logged in",
:data => {} } # { :auth_token => current_user.authentication_token } }
end
def failure
render :status => 401,
:json => { :success => false,
:info => "Login Failed",
:data => {} } end
end
When the login credentials are right, the create function is invoked and it returns the right response. When login credentials are wrong the failure function is not invoked while its not going into the sessionController API but Devise::SessionsController instead and return the response in the Devise::SessionsController. Anyone have any ideas? Thanks alot!
Aucun commentaire:
Enregistrer un commentaire