Created
February 9, 2016 14:00
-
-
Save narada85/702e6cad8f91edca815d 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
elsif user_auth["provider"].eql?("facebook") | |
authentication = Authentication.find_by_provider_and_uid(user_auth['provider'], user_auth['uid']) | |
if authentication | |
@user = authentication.user | |
@user.notification_token = user_auth["user"]["notification_token"] | |
sign_in(:user, @user, store: false) | |
render :json => {:status => "success", :user => @user.info} and return | |
else | |
#Facebook will begin to issue app-scoped user IDs when people first log into an instance of your app coded against v2.0 of the API. With app-scoped IDs, the ID for the same user will be different between apps. | |
@user = User.where(:email => user_auth["user"]["email"].downcase, :is_completed => true).first | |
old_authentication = Authentication.find_by_provider_and_user_id(user_auth['provider'], @user.id) | |
if old_authentication | |
old_authentication.update_attributes(:uid => user_auth['uid']) | |
render :json => {:status => "success", :user => @user.info} and return | |
else | |
render :json => {:status => "errored", :error_id => 172, :errors => ["Please sign up using Facebook"]} and return | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment