Module: Omniauth::MultipleProviders::AuthHashContainable
- Extended by:
- ActiveSupport::Concern
- Included in:
- ProviderUser
- Defined in:
- lib/omniauth/multiple_providers/models/concerns/auth_hash_containable.rb
Overview
# Usage class ProviderUser < ActiveRecord::Base
include Omniauth::MultipleProviders::AuthHashContainable
end
Instance Method Summary collapse
-
#update_by(auth) ⇒ Object
TODO use method_missing.
- #update_by_facebook(auth) ⇒ Object
- #update_by_github(auth) ⇒ Object
- #update_by_google_oauth2(auth) ⇒ Object
-
#update_by_twitter(auth) ⇒ Object
USAGE: if you want customize, you just overwrite follow methods.
Instance Method Details
#update_by(auth) ⇒ Object
TODO use method_missing
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/omniauth/multiple_providers/models/concerns/auth_hash_containable.rb', line 21 def update_by(auth) self.provider = auth['provider'] self.uid = auth['uid'] case auth['provider'] when 'twitter' update_by_twitter(auth) when 'facebook' update_by_facebook(auth) when 'github' update_by_github(auth) when 'google_oauth2' update_by_google_oauth2(auth) end self.save end |
#update_by_facebook(auth) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/omniauth/multiple_providers/models/concerns/auth_hash_containable.rb', line 46 def update_by_facebook(auth) self.access_token = auth['credentials']['token'] self.expires_at = auth['credentials']['expires_at'] self.email = auth['info']['email'] self.name = auth['info']['name'] self.nickname = auth['info']['nickname'] self.image_path = auth['info']['image'] self.gender = auth['extra']['raw_info']['gender'] self.locale = auth['extra']['raw_info']['locale'] end |
#update_by_github(auth) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/omniauth/multiple_providers/models/concerns/auth_hash_containable.rb', line 57 def update_by_github(auth) self.email = auth['info']['email'] self.name = auth['info']['name'] self.nickname = auth['info']['nickname'] self.image_path = auth['info']['image'] self.access_token = auth['credentials']['token'] self.secret = auth['credentials']['secret'] self.refresh_token = auth['credentials']['refresh_token'] self.expires_at = auth['credentials']['expires_at'] end |
#update_by_google_oauth2(auth) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/omniauth/multiple_providers/models/concerns/auth_hash_containable.rb', line 68 def update_by_google_oauth2(auth) self.email = auth['info']['email'] self.name = auth['info']['name'] self.access_token = auth['credentials']['token'] self.refresh_token = auth['credentials']['refresh_token'] self.expires_at = auth['credentials']['expires_at'] self.image_path = auth['info']['image'] self.gender = auth['extra']['raw_info']['gender'] self.locale = auth['extra']['raw_info']['locale'] end |
#update_by_twitter(auth) ⇒ Object
USAGE: if you want customize, you just overwrite follow methods.
38 39 40 41 42 43 44 |
# File 'lib/omniauth/multiple_providers/models/concerns/auth_hash_containable.rb', line 38 def update_by_twitter(auth) self.access_token = auth['credentials']['token'] self.secret = auth['credentials']['secret'] self.name = auth['info']['nickname'] self.nickname = auth['info']['nickname'] self.image_path = auth['info']['image'] end |