0
我使用omniauth-facebook gem和Devise成功实施了Facebook身份验证。然而,我想要做的是,在Facebook认证之后,将它们重定向到一个可以在创建记录之前指定密码(和密码确认)的表单。Rails - 在Facebook Omniauth注册期间获得其他字段
我该怎么做?
我的代码是基于创业板的文档上非常标准:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.from_omniauth(request.env["omniauth.auth"])
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication
set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
def failure
redirect_to root_path
end
end
user.rb
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.email = auth.info.email
user.username = auth.info.name.downcase.gsub(" ", "")
end
end
好,这是omniauth的整个目的,用户不必记住password..just好奇,为什么你想呢? –
为true。其实,我也想要其他领域。如他们的国家。 – yellowreign