0
我使用Ruby on Rails的Github中的Omniauth-facebook gem。我有幾個關於omniauth-facebook gem的問題。最好的omniauth gem for rails
我正在使用以下函數從Facebook獲取數據,但每次用戶登錄和註冊時都會調用此函數。
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.id = auth.uid
user.uid = auth.uid
user.name = auth.info.name
user.username = auth.info.nickname
user.email = auth.info.email
user.gender = auth.extra.raw_info.gender
user.is_admin = false
user.picture = "http://graph.facebook.com/#{auth.uid}/picture?type=large&height=324&width=580"
user.updated_at = auth.extra.raw_info.updated_time
user.oauth_token = auth.credentials.token
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
user.save!
end
end
我該如何區分對方的註冊和登錄功能?
另一方面,我想在用戶登錄或發佈內容時發佈用戶的牆。我怎麼能在Omniauth-Facebook的寶石?
謝謝。