module Omniauth::MultipleProviders::Omniauthable::ClassMethods
Public Instance Methods
create_by_oauth(auth)
click to toggle source
# File lib/omniauth/multiple_providers/models/concerns/omniauthable.rb, line 62 def create_by_oauth(auth) case auth['provider'] when 'twitter' # Twitter not give me email from api User.create_by_twitter(auth) when 'facebook', 'google_oauth2', 'github' # Other api give me email User.create_by_omniauth(auth) else User.new end end
create_by_omniauth(auth)
click to toggle source
# File lib/omniauth/multiple_providers/models/concerns/omniauthable.rb, line 75 def create_by_omniauth(auth) u = User.new u.email = auth['info']['email'] u.name = auth['info']['name'] password = Devise.friendly_token[0,20] u.password = password u.password_confirmation = password u.skip_confirmation! # Because we get confirmed (by providers) email ! u.save u end
create_by_twitter(auth)
click to toggle source
# File lib/omniauth/multiple_providers/models/concerns/omniauthable.rb, line 87 def create_by_twitter(auth) # https://github.com/arunagw/omniauth-twitter#authentication-hash u = User.new # u.email = auth['info']['email'] # Twitter not give me email from api u.name = auth['info']['name'] password = Devise.friendly_token[0,20] u.password = password u.password_confirmation = password u.save u end
find_by_oauth(auth)
click to toggle source
# File lib/omniauth/multiple_providers/models/concerns/omniauthable.rb, line 47 def find_by_oauth(auth) if up = ProviderUser.find_by(uid: auth['uid'], provider: auth['provider']) up.user else # Hmmm... # FIXME to be configuratable # Do this If you trust provider email if user = User.find_by(email: auth['email']) user else nil end end end
find_or_create_by_oauth(auth, current_user)
click to toggle source
# File lib/omniauth/multiple_providers/models/concerns/omniauthable.rb, line 30 def find_or_create_by_oauth(auth, current_user) @user = if current_user current_user.create_or_update_provider_user_by(auth) current_user else if user = User.find_by_oauth(auth) user.create_or_update_provider_user_by(auth) user else user = User.create_by_oauth(auth) user.save user.create_or_update_provider_user_by(auth) user end end end