我为登录系统设计了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