Class: C80NewsTz::User

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/c80_news_tz/user.rb

Class Method Summary collapse

Class Method Details

.from_omniauth(auth_hash) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'app/models/c80_news_tz/user.rb', line 6

def self.from_omniauth(auth_hash)
  user = find_or_create_by(uid: auth_hash['uid'], provider: auth_hash['provider'])
  user.name = auth_hash['info']['name']
  user.location = get_social_location_for user.provider, auth_hash['info']['location']
  user.image_url = auth_hash['info']['image']
  user.url = get_social_url_for user.provider, auth_hash['info']['urls'] #[user.provider.capitalize]
  user.save!
  user
end