I have a app running on devise and omniauth for user registrations. However when someone logins with facebook using omniauth I want to display some extra info for that user. However I can't find a way to identify if that user is signed in with facebook.
I believe it has something to do with the 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 %>