How to check if a user is signed up with omniauth

I have an app running on a device and omniauth to register users. However, when someone logs in with facebook using omniauth, I want to display additional information for that user. However, I cannot find a way to determine if this user was signed up with facebook.

I believe it has something to do with devise_helper (user_signed_in?), But I'm not sure how to use it with omniauth.

user.rb

  def self.find_for_facebook_oauth(auth)
    where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
      user.name = auth.info.name
      user.provider = auth.provider
      user.uid = auth.uid
      user.email = auth.info.email
      user.password = Devise.friendly_token[0,20]
      user.username = auth.info.email
      user.token = auth.credentials.token
      user.save!
    end
  end

      

devise.rb

config.omniauth :facebook, ENV["APP_ID"], ENV["APP_SECRET"],
      {:scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}} 

      

code

<% if current_user.token %>
    <% @graph = Koala::Facebook::API.new(current_user.token) %>
    <%= @friends = @graph.get_connections("me", "friends").to_a %>
        <%= @friends.each do |friend| %>
            <%= puts friend["name"] %>
        <% end %>
<% end %>

      

0


source to share





All Articles