correct facebook logic
This commit is contained in:
parent
ac905d4a08
commit
982b763216
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue