Skip to content

Instantly share code, notes, and snippets.

@GarthDB
Created October 17, 2011 18:46
Show Gist options
  • Save GarthDB/1293429 to your computer and use it in GitHub Desktop.
Save GarthDB/1293429 to your computer and use it in GitHub Desktop.
user login
class UsersController < ApplicationController
def login
error = false;
@user = User.find_by_email(params['email']);
if(@user.nil?)
error = true
else
error = [email protected]_password?(params['password'])
end
error_response = {:response => 'Error', :message => 'Not a valid email/password'}
respond_to do |format|
if(error)
format.json { render :json => error_response, :status=> 401}
else
format.json { render :json => @user}
end
end
end
def index
end
def new
end
def create
end
def edit
end
def update
end
def destroy
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment