Module: Devise::Models::G5Authenticatable::ClassMethods
- Defined in:
- lib/devise_g5_authenticatable/models/g5_authenticatable.rb
Instance Method Summary collapse
- #find_and_update_for_g5_oauth(oauth_data) ⇒ Object
- #find_for_g5_oauth(oauth_data) ⇒ Object
- #new_with_session(params, session) ⇒ Object
Instance Method Details
#find_and_update_for_g5_oauth(oauth_data) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/devise_g5_authenticatable/models/g5_authenticatable.rb', line 80 def find_and_update_for_g5_oauth(oauth_data) resource = find_for_g5_oauth(oauth_data) if resource resource.update_g5_credentials(oauth_data) resource.save! end resource end |
#find_for_g5_oauth(oauth_data) ⇒ Object
74 75 76 77 78 |
# File 'lib/devise_g5_authenticatable/models/g5_authenticatable.rb', line 74 def find_for_g5_oauth(oauth_data) found_user = find_by_provider_and_uid(oauth_data.provider.to_s, oauth_data.uid.to_s) return found_user if found_user.present? find_by_email_and_provider(oauth_data.info.email, oauth_data.provider.to_s) end |
#new_with_session(params, session) ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/devise_g5_authenticatable/models/g5_authenticatable.rb', line 89 def new_with_session(params, session) defaults = ActiveSupport::HashWithIndifferentAccess.new if auth_data = session && session['omniauth.auth'] defaults[:email] = auth_data.info.email defaults[:provider] = auth_data.provider defaults[:uid] = auth_data.uid end new(defaults.merge(params)) end |