Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narada85/702e6cad8f91edca815d to your computer and use it in GitHub Desktop.
Save narada85/702e6cad8f91edca815d to your computer and use it in GitHub Desktop.
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