Module: Ddr::Auth::User::ClassMethods

Defined in:
lib/ddr/auth/user.rb

Instance Method Summary collapse

Instance Method Details

#find_by_user_key(key) ⇒ Object



25
26
27
# File 'lib/ddr/auth/user.rb', line 25

def find_by_user_key(key)
  send("find_by_#{user_key_attribute}", key)
end

#from_omniauth(auth) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/ddr/auth/user.rb', line 29

def from_omniauth(auth)
  user = find_by_user_key(auth.uid) || 
    new(user_key_attribute => auth.uid, :password => Devise.friendly_token)
  user.update!(email: auth.info.email, 
               display_name: auth.info.name,
               first_name: auth.info.first_name,
               last_name: auth.info.last_name,
               nickname: auth.info.nickname)
  user
end