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

时间:2011-06-20 23:56:07

标签: ruby-on-rails ruby-on-rails-3 devise omniauth

使用rails 3 +设计+ 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

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

想法?感谢

1 个答案:

答案 0 :(得分:5)

似乎你正在使用omietuthable from devise。在这种情况下,您可以看到Devise :: OmniauthCAllbackController#failure action here的代码。

所以,你获得了控制器,你必须创建一个控制器,例如omniauth_controller as -

class OmniauthController < Devise::OmniauthCAllbackController

   def failure
      #handle you logic here..
      #and delegate to super.
      super
   end
end

这应该有效。您还需要为omniauth控制器添加“devise_for”路由。