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



18
19
20
# File 'lib/ddr/auth/user.rb', line 18

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

#from_omniauth(auth) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/ddr/auth/user.rb', line 22

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