我按照此处的步骤操作,在合并帐户时遇到了一些问题
根据说明,我将以下方法添加到我的 ApplicationController
def after_sign_in_path_for(resource)
# Merge data from Facebook with her current account
if session["facebook_data"] && current_user.facebook_uid.nil?
current_user.facebook_uid = session["facebook_data"]["uid"]
current_user.save(:validate => false)
end
# Countermeasure against session fixation
session.keys.grep(/^facebook\./).each { |k| session.delete(k) }
super
end
但是,我在 ApplicationController 中得到了一个空会话 ["facebook_data"],即使我在调用此方法的回调 app/controllers/users/omniauth_callbacks_controller.rb 中看到了正确的会话值:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user)
if user && user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
sign_in_and_redirect user, :event => :authentication
else
session["facebook_data"] = env["omniauth.auth"]
redirect_to new_user_session_url # this redirect invokes the after_sign_in_path_for method in ApplicationController
end
end
end
我在这里想念什么?