Class: User

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

Class Method Summary collapse

Class Method Details

.find_or_create_with_omniauth(auth) ⇒ Object



2
3
4
5
6
7
# File 'app/models/user.rb', line 2

def self.find_or_create_with_omniauth(auth)
  user = self.find_or_create_by_provider_and_uid(auth["provider"], auth["uid"])
  user.assign_attributes({:name => auth["info"]["name"], :email => auth["info"]["email"], :photo_url => auth["info"]["image"], :access_token => auth["credentials"]["token"], :extra => (auth["extra"]["raw_info"] rescue nil)}, :without_protection => true)
  user.save(validate: false)
  user
end