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 |
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
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