一个用户有多个uid与omniauth facebook登录

时间:2015-08-05 05:57:42

标签: ruby-on-rails-4 omniauth omniauth-facebook

我为登录系统设计了omniauth和facebook插件。

然而,似乎同一个Facebook帐户将返回不同的令牌from googleapiclient import build import hashlib password = 'secret' hashed_password = hashlib.sha1(password).hexdigest() params = {'password': hashed_password} # 'http' is a httplib2.Http() object with the appropriate credentials to # access the Google API directory = build('admin', 'directory_v1', http=http) username = 'batman@batcave.org' directory.users().update(userKey=username, body=params).execute()

我如何处理Rails中的各种情况。

我的新设计方法有不良副作用吗?

我计划只使用facebook omniauth作为登录我系统的唯一方法。

原始创建用户方法

uid

新设计的方法

def self.from_omniauth(auth)
  where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
    user.provider = auth.provider
    user.uid = auth.uid
    user.email = auth.info.email
    user.password = Devise.friendly_token[0,20]
  end
end

样本文件

def self.from_omniauth(auth)
  where(email: auth.email).first_or_create do |user|
    user.provider = auth.provider
    user.uid = auth.uid
    user.email = auth.info.email
    user.password = Devise.friendly_token[0,20]
  end
end

0 个答案:

没有答案
相关问题