我正在使用来自Ruby on Rails的Github的Omniauth-facebook gem。关于omniauth-facebook gem,我有几个问题。
我使用以下函数从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 gem中做到这一点?
谢谢。