我使用omniauth-facebook gem和Devise成功实施了Facebook身份验证。但是,我想要做的是,在Facebook验证之后,将它们重定向到一个表单,在该表单中,他们可以在创建记录之前指定其密码(和密码确认)。
我该怎么做?
我的代码非常标准,基于gem的文档:
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
答案 0 :(得分:0)
如果我理解正确,您需要用户在浏览应用之前填写profile
页面。以下内容应该有所帮助..
在application_controller.rb
,
def after_sign_in_path_for(resource)
resource.profile_complete? ? root_path : user_profile_path(resource)
end