Skip to content

Instantly share code, notes, and snippets.

@jsooriah
Created January 23, 2014 07:34
Show Gist options
  • Save jsooriah/8574465 to your computer and use it in GitHub Desktop.
Save jsooriah/8574465 to your computer and use it in GitHub Desktop.
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
@jsooriah
Copy link
Author

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