我正在覆盖设备会话控制器......它可以工作(我可以使用 json 登录),但我无法让它重定向到另一个错误操作:
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
我也试过:
if resource.nil?
puts "NIL!"
end
响应错误的登录凭据,我总是得到相同的默认设计 json 错误:
{error: "You need to sign in or sign up before continuing."}
我究竟做错了什么?