OmniauthCallbacksController#failure - 当点击"不允许"进行facebook连接时

AnA*_*ice 2 ruby-on-rails devise omniauth ruby-on-rails-3

使用rails 3 + devise + omniauth到facebook连接.在权限对话框中,如果用户单击"不允许",则将用户重定向到:

Started GET "/users/auth/facebook/callback?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request." for 127.0.0.1 at Mon Jun 20 16:54:42 -0700 2011
  Processing by Devise::OmniauthCallbacksController#failure as HTML
  Parameters: {"error_description"=>"The user denied your request.", "error_reason"=>"user_denied", "error"=>"access_denied"}
Redirected to http://localhost:3000/users/sign_in
Completed 302 Found in 2ms
Run Code Online (Sandbox Code Playgroud)

如何获得控制权并提供.js文件以优雅地处理此问题.现在,它正在重定向到根并显示该站点是一个小小的对话框.

想法?谢谢

rtd*_*tdp 5

似乎你正在使用omniauthable from devise.在这种情况下,您可以在此处查看Devise :: OmniauthCAllbackController#failure action的代码.

所以,你获得控制器,你必须创建一个控制器说omniauth_controller为 -

class OmniauthController < Devise::OmniauthCAllbackController

   def failure
      #handle you logic here..
      #and delegate to super.
      super
   end
end
Run Code Online (Sandbox Code Playgroud)

这应该工作.您还需要为omniauth控制器添加"devise_for"路由.