Guest User

Untitled

a guest
Apr 27th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. class User < ActiveRecord::Base
  2. def self.from_omniauth(auth)
  3. where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
  4. user.provider = auth.provider
  5. user.uid = auth.uid
  6. user.name = auth.info.name
  7. user.oauth_token = auth.credentials.token
  8. user.oauth_expires_at = Time.at(auth.credentials.expires_at)
  9. user.save!
  10. end
  11. end
  12. end
Advertisement
Add Comment
Please, Sign In to add comment