Created
March 9, 2013 18:55
-
-
Save marawannwh/5125273 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
def authenticate_with_email_and_password | |
passenger = Passenger.find_by_email(params[:email]) | |
if passenger | |
if passenger.valid_password?(params[:password]) | |
if passenger.confirmed? | |
passenger | |
else | |
render :json => {:result => "failure",:error => "not confirmed"}.to_json | |
return | |
end | |
else | |
render :json => {:result => "failure",:error => "wrong email or password"}.to_json | |
return | |
end | |
else | |
render :json => {:result => "failure",:error => "wrong email or password"}.to_json | |
return | |
end | |
end | |
def login | |
passenger = authenticate_with_email_and_password | |
passenger.reset_authentication_token! | |
@token = passenger.authentication_token | |
@result = "success" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment