Module: Devise::Models::AuthIdentitable::ClassMethods

Defined in:
lib/devise/models/auth_identitable.rb

Instance Method Summary collapse

Instance Method Details

#setup_user_from_third_party(provider:, uid:, email:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/devise/models/auth_identitable.rb', line 14

def setup_user_from_third_party(provider:, uid:, email:)
  raise LeveretAuth::Errors::ThirdPartyNotProvideEmail if email.nil? || email.empty?

  identity = LeveretAuth::Identities.find_or_initialize_by(uid: uid, provider: provider)
  return identity.user unless identity.new_record?

  identity.user = setup_with_temporary_passsword(email, &LeveretAuth.configuration.before_user_save)
  identity.save!
  identity.user
end