所以我试图将OmniAuth添加到我的Rails应用程序中,该应用程序目前使用Devise + Pundit进行身份验证和授权。我添加了一个"登录Facebook"按钮并对其进行配置,以便弹出Facebook登录窗口。但是,在您提交该表单后,该应用程序崩溃了一个"太多的重定向"错误。我还认为我可能误解了有关users / auth /:provider路由的#passthru操作。
以下是相关路线:
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_omniauth_authorize GET|POST /users/auth/:provider(.:format) users/omniauth_callbacks#passthru {:provider=>/facebook/}
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) users/omniauth_callbacks#(?-mix:facebook)
和routes.rb:
Rails.application.routes.draw do
get 'home/index'
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
resources :movies
root 'home#index'
end
这是控制台输出,它在循环中保持打印:
Started GET "/users/auth/facebook?code=AQAIAC2szE1y30Ob9o7SSHfu4KckM4OxBNa1UuzvjiNYqD93_mRMTcfE2Hz01ZSDVOzRJW0DxHMtRHIeWOJW6T2Uvfc4heeoM5cNVh6QXEQsokSOh0jfcFjFsWlyzj8SKZSS9Az-MwaaekwqrLrfvTYii2ibhbzadhoymD2omBcevmPvfQlnfGQolV7E78R_nD7YoEshNLQ3GejPqMXGbBgs4L3YFP3D-5B_rcIOmNYopnpERQTtpKep1Apv5OmqBGiJy-UWH9_cPPCtNMpBjPOjUeUGG9fzE4nzEoMvAZzDQj4LMBAxm0DWqFdetFQ34Eg&state=3d59887ccde2c2be1677f6f75010bf4a3eccc3021017ec89" for 71.212.102.26 at 2016-04-20 20:08:37 +0000
Started GET "/users/auth/facebook?code=AQAIAC2szE1y30Ob9o7SSHfu4KckM4OxBNa1UuzvjiNYqD93_mRMTcfE2Hz01ZSDVOzRJW0DxHMtRHIeWOJW6T2Uvfc4heeoM5cNVh6QXEQsokSOh0jfcFjFsWlyzj8SKZSS9Az-MwaaekwqrLrfvTYii2ibhbzadhoymD2omBcevmPvfQlnfGQolV7E78R_nD7YoEshNLQ3GejPqMXGbBgs4L3YFP3D-5B_rcIOmNYopnpERQTtpKep1Apv5OmqBGiJy-UWH9_cPPCtNMpBjPOjUeUGG9fzE4nzEoMvAZzDQj4LMBAxm0DWqFdetFQ34Eg&state=3d59887ccde2c2be1677f6f75010bf4a3eccc3021017ec89" for 71.212.102.26 at 2016-04-20 20:08:37 +0000
Cannot render console from 71.212.102.26! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Cannot render console from 71.212.102.26! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
I, [2016-04-20T20:08:37.157387 #20936] INFO -- omniauth: (facebook) Request phase initiated.