Created
January 23, 2014 07:34
-
-
Save jsooriah/8574465 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V1::SessionsController < Devise::SessionsController | |
prepend_before_filter :require_no_authentication, :only => [:create] | |
skip_before_filter :verify_authenticity_token, :if => Proc.new { |c| c.request.format == 'application/json' } | |
before_filter :validate_auth_token, :except => :create | |
include Devise::Controllers::Helpers | |
include ApiHelper | |
respond_to :json | |
def create | |
resource = User.find_for_database_authentication(:email => params[:user][:email]) | |
return failure unless resource | |
if resource.valid_password?(params[:user][:password]) | |
sign_in(:user, resource) | |
resource.ensure_authentication_token! | |
render :json=> {:success => true, :token => resource.authentication_token} | |
return | |
end | |
failure | |
end |
Salut Joël,
Il me semble déjà que tu as un problème de routes.
Ton POST "/users/sign_in.json" tape sur Devise::SessionsController#create alors qu'il devrait taper sur Api::V1::SessionsController#create me semble-t-il
yo !
je pensais justement à ça ce matin !!
Many Thanks bartocc !
Et excellent année ;) !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Started POST "/users/sign_in.json" for 127.0.0.1 at 2014-01-23 01:19:48 +0100
Processing by Devise::SessionsController#create as JSON
Parameters: {"password"=>"[FILTERED]", "email"=>"[email protected]", "session"=>{"password"=>"[FILTERED]", "format"=>"json", "email"=>"[email protected]"}}
Completed 401 Unauthorized in 6ms
Processing by Devise::SessionsController#new as JSON
Parameters: {"password"=>"[FILTERED]", "email"=>"[email protected]", "session"=>{"password"=>"[FILTERED]", "format"=>"json", "email"=>"[email protected]"}}
Completed 406 Not Acceptable in 165ms
ActionController::UnknownFormat (ActionController::UnknownFormat):
actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:372:in
retrieve_collector_from_mimes' actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:327:in
respond_with'devise (3.0.3) app/controllers/devise/sessions_controller.rb:10:in `new'