2011-10-26 56 views

回答

0

自己想出來。

OmniAuth Overview wiki頁面提示下面application_controller.rb修復來修復丟失的會話:

def authenticate_user! 
    if !current_user 
    # This should work, but session is lost. 
    # session[:return_to] = request.fullpath 
    redirect_to user_omniauth_authorize_path(:google_apps, :origin => request.fullpath) 
    end 
end 

,而不是在上面的代碼片段使用request.fullpath但是,關鍵是要使用request.env [「HTTP_REFERER」]改爲。