Skip to content

Instantly share code, notes, and snippets.

@marwan-nwh
Created March 9, 2013 18:55
Show Gist options
  • Save marwan-nwh/5125273 to your computer and use it in GitHub Desktop.
Save marwan-nwh/5125273 to your computer and use it in GitHub Desktop.
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