Module: Omniauth::MultipleProviders::Omniauthable

Extended by:
ActiveSupport::Concern
Defined in:
lib/omniauth/multiple_providers/models/concerns/omniauthable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#create_or_update_provider_user_by(auth) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/omniauth/multiple_providers/models/concerns/omniauthable.rb', line 12

def create_or_update_provider_user_by(auth)
  if provider_user = self.provider_users.find_by(uid: auth['uid'], provider: auth['provider'])
    provider_user.update_by(auth)
  else
    provider_user = self.provider_users.build
    provider_user.update_by(auth)
  end
end

#oauthed?(provider_name) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/omniauth/multiple_providers/models/concerns/omniauthable.rb', line 21

def oauthed?(provider_name)
  if up = self.provider_users.find_by(provider: provider_name)
    up
  else
    nil
  end
end