成功注册 Facebook(未登录)后,我正在尝试重定向用户。
我想在用户第一次/getstarted/welcome
注册后重定向到。
我的omniauth回调是:
def facebook
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user ||=
User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
# This will throw if @user is not activated
sign_in_and_redirect @user, event: :authentication
if is_navigational_format?
set_flash_message(:notice, :success, kind: "Facebook")
end
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
对于我使用的设计
def after_sign_up_path_for(source)
'/getstarted/welcome'
end
我的用户模型:
脸书设置
def self.find_for_facebook_oauth(auth, signed_in_resource = nil)
user = User.where(provider: auth.provider, uid: auth.uid).first
if user.present?
user
else
user = User.create(first_name:auth.extra.raw_info.first_name,
last_name:auth.extra.raw_info.last_name,
facebook_link:auth.extra.raw_info.link,
user_name:auth.extra.raw_info.name,
provider:auth.provider,
uid:auth.uid,
email:auth.info.email,
password:Devise.friendly_token[0,20])
end
end
有人可以帮我设置吗?