I redefine the device session controller . It works (I can log in using 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 the wrong sign_in credentials:
{error: "You need to sign in or sign up before continuing."}
What am I doing wrong?
Stpn source share