mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
correct facebook logic
This commit is contained in:
parent
ac905d4a08
commit
982b763216
2 changed files with 2 additions and 5 deletions
|
@ -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 a new issue