From 982b763216a6109ab5dd108a3e3851b5f183bea9 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 26 Aug 2013 18:01:01 +1000 Subject: [PATCH] correct facebook logic --- lib/auth/authenticator.rb | 4 ---- lib/auth/facebook_authenticator.rb | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/auth/authenticator.rb b/lib/auth/authenticator.rb index f6a67f3f3..44a371cf7 100644 --- a/lib/auth/authenticator.rb +++ b/lib/auth/authenticator.rb @@ -14,10 +14,6 @@ class Auth::Authenticator # not required end - def lookup_user(user_info, email) - user_info.try(:user) || User.where(email: email).first - end - # hook used for registering omniauth middleware, # without this we can not authenticate def register_middleware(omniauth) diff --git a/lib/auth/facebook_authenticator.rb b/lib/auth/facebook_authenticator.rb index bb5d18969..c070eaa25 100644 --- a/lib/auth/facebook_authenticator.rb +++ b/lib/auth/facebook_authenticator.rb @@ -17,8 +17,9 @@ class Auth::FacebookAuthenticator < Auth::Authenticator result.extra_data = facebook_hash user_info = FacebookUserInfo.where(facebook_user_id: facebook_hash[:facebook_user_id]).first + result.user = user_info.try(:user) - if !user_info && result.user = lookup_user(user_info, email) + if !result.user && result.user = User.where(email: Email.downcase(email)).first FacebookUserInfo.create({user_id: result.user.id}.merge(facebook_hash)) end