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
ruby-on-rails devise omniauth


source to share


No one has answered this question yet

See similar questions:

3
Devise - Omniauth - Hide password fields if user signed up via Facebook

or similar:

1339
How can I rename a database column in Ruby on Rails migrations?
548
How to check if a particular key is present in a hash or not?
368
No routes match "/ users / sign_out" devise rails 3
12
Editing Users with Devise and Omniauth
3
Login with Devise, Omniauth and SoundCloud
2
Single sign-on with Devise and OmniAuth
1
ActionController :: RoutingError Signed OmniAuth
0
Only allow users to register and register with Omniauth
0
Devise / OmniAuth does not sign some users
0
NoAuthorizationCodeError for facebook omniauth



All Articles
Loading...
X
Show
Funny
Dev
Pics