Skip to content

Instantly share code, notes, and snippets.

@leonardorb
Created April 26, 2013 13:30
Show Gist options
  • Save leonardorb/5467382 to your computer and use it in GitHub Desktop.
Save leonardorb/5467382 to your computer and use it in GitHub Desktop.
class Api::V1::SessionsController < ::Devise::SessionsController
#skip_before_filter :verify_authenticity_token
def create
@user = User.find_for_authentication(:email => params[:user][:email])
if @user.nil?
render :json => {:success => false, :message => "Incorrect email or password."}, :status => 401
else
if @user.valid_password?(params[:user][:password])
sign_in(@user)
else
render :json => {:success => false, :message => "Incorrect email or password."}, :status => 401
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment