Module: UserOmniauthConcern

Extended by:
ActiveSupport::Concern
Includes:
UserOmniauthFacebookConcern
Defined in:
app/models/concerns/user_omniauth_concern.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

Link user with an omniauth provider.

Parameters:

  • auth (OmniAuth::AuthHash|Hash)

    The data with omniauth info.


46
47
48
# File 'app/models/concerns/user_omniauth_concern.rb', line 46

def link_with_omniauth(auth)
  identities.find_or_initialize_by(provider: auth[:provider], uid: auth[:uid])
end

Link user with an omniauth provider. This method would immediately set the attributes in the database.

Parameters:

  • auth (OmniAuth::AuthHash|Hash)

    The data with omniauth info.

Returns:

  • (Boolean)

    True if success, otherwise false.


55
56
57
58
# File 'app/models/concerns/user_omniauth_concern.rb', line 55

def link_with_omniauth!(auth)
  link_with_omniauth(auth)
  save
end