I am overriding Device sessions controller... It works (I can log in with json), but I cannot get it to redirect to another action on error:
class Users::SessionsController < Devise::SessionsController
def create
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#no")
return invalid_login_attempt unless resource
sign_in(resource_name, resource)
#respond_with resource, :location => redirect_location(resource_name, resource)
respond_to do |format|
format.json { render :status => 200, :json => { :success => true, :auth_token => resource.authentication_token, :user => resource } }
end
end
def no
puts "NO!"
return render:json => {:success => false, :errors => alert}
end
end
I also tried:
if resource.nil?
puts "NIL!"
end
I always get the same default Devise json error in response to wrong sign_in credentials:
{error: "You need to sign in or sign up before continuing."}
What am I doing wrong?