Module: UserOmniauthFacebookConcern::ClassMethods

Defined in:
app/models/concerns/user_omniauth_facebook_concern.rb

Instance Method Summary collapse

Instance Method Details

#new_with_session(params, session) ⇒ Object

A convenience method that receives both parameters and session to initialize a user. This is a override of Devise::Models::Registerable::ClassMethods#new_with_session


8
9
10
11
12
13
14
15
16
17
# File 'app/models/concerns/user_omniauth_facebook_concern.rb', line 8

def new_with_session(params, session)
  super.tap do |user|
    facebook_data = session['devise.facebook_data']&.deep_symbolize_keys
    if facebook_data && (info = facebook_data[:info])
      user.name ||= info[:name] if info[:name]
      user.email ||= info[:email] if info[:email]
      user.link_with_omniauth(facebook_data)
    end
  end
end