【发布时间】:2016-03-19 21:03:13
【问题描述】:
我使用 gem 'Omniauth' 安装了 Facebook 注册,现在用户可以使用它进行连接。我在我的网站中使用了 Devise。
我想知道在用户连接到 Facebook 后如何重定向路径(例如完成注册),因为他们必须填写包含特定信息的表单。
我是否在现有控制器文件中添加新条件?我创建了一个名称为omniauth_callbacks_controller.rb
代码是:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
user = User.find_for_facebook_oauth(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
end
我尝试这样做
if user.persisted?
sign_in_and_redirect user, event: :authentication
set_flash_message(:notice, :success, kind: 'Facebook') if is_navigational_format?
user.thing_you_want_to_check.blank?
redirect_to finish_sign_up_path
else
session['devise.facebook_data'] = request.env['omniauth.auth']
redirect_to new_user_registration_url
end
end
end
【问题讨论】:
标签: ruby-on-rails facebook devise