lib/omniauth/multiple_providers/models/concerns/omniauthable.rb in omniauth-multiple_providers-0.0.2 vs lib/omniauth/multiple_providers/models/concerns/omniauthable.rb in omniauth-multiple_providers-0.0.3
- old
+ new
@@ -46,15 +46,21 @@
def find_by_oauth(auth)
if up = ProviderUser.find_by(uid: auth['uid'], provider: auth['provider'])
up.user
else
- nil
+ # 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
def create_by_oauth(auth)
- logger.debug "##### Auth Hash: #{auth.to_json}"
case auth['provider']
when 'twitter'
# Twitter not give me email from api
User.create_by_twitter(auth)
when 'facebook', 'google_oauth2', 'github'