Cannot override after_omniauth_failure_path_for in Devise

165 views
Skip to first unread message

mikaso

unread,
Apr 22, 2012, 3:13:24 AM4/22/12
to Devise
I have my class Users::OmniauthCallbacksController <
Devise::OmniauthCallbacksController and I'm overriding the
after_omniauth_failure_path_for method:

protected
def after_omniauth_failure_path_for resource
'/report_failure'
end

But the super one is the one that gets called.

I suspects that it's because the passthru workaround:

devise_for :users do
get '/users/auth/:provider' => 'users/
omniauth_callbacks#passthru'
end

Does anybody knows how to overcome this issue? I'm using Devise 2.0.4

This is the log file report:

Started GET "/users/auth/facebook/callback?
error_reason=user_denied&error=access_denied&error_description=The+user
+denied+your+request." for 77.124.184.115 at 2012-04-19 11:34:46 +0000
Processing by Devise::OmniauthCallbacksController#failure as HTML
Parameters: {"error_reason"=>"user_denied",
"error"=>"access_denied", "error_description"=>"The user denied your
request."}
Redirected to http://myapp.com/users/sign_in
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)

Thank you

Carlos Antonio da Silva

unread,
Apr 22, 2012, 9:25:37 AM4/22/12
to plataforma...@googlegroups.com
Seems weird, I don't know if the passthru has something to do with it. What happens if you move the failure method from devise (copy) to your users omniauth controller, does it work?

-- 
At.
Carlos Antonio

east2006 east2006

unread,
Apr 22, 2012, 3:44:51 PM4/22/12
to plataforma...@googlegroups.com
No, I tried it, can't override failure() as well, the facebook() function gets called in my class

Carlos Antonio da Silva

unread,
Apr 22, 2012, 5:13:08 PM4/22/12
to plataforma...@googlegroups.com
How does the #facebook method get called if it is responding with #failure? Sorry I didn't understand.
Does it work if you remove the passthru code?

-- 
At.
Carlos Antonio

east2006 east2006

unread,
Apr 23, 2012, 6:08:52 AM4/23/12
to plataforma...@googlegroups.com
Thanks you Carlos, removing the passthru made it work.
 

  devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks", :registrations => "registrations", :confirmations => "confirmations", :passwords => "passwords"}
 
#  devise_for :users do
#    get '/users/auth/:provider'  => 'users/omniauth_callbacks#passthru'
#  end
 
It looks like everything is working fine without the passthru (I'm using the manual sign-in and only Facebook as the 3rd party authenticator)

What I'm I missing by not having the passthru workaround?
 
Thank you

Carlos Antonio da Silva

unread,
Apr 23, 2012, 7:42:29 AM4/23/12
to plataforma...@googlegroups.com
If I remember correctly, the passthru is only required if you use glob routes - like *path. Here's a question on stack overflow: http://stackoverflow.com/questions/5531263/omniauth-doesnt-work-with-route-globbing-in-rails3.

Other than that I believe it's not required.

-- 
At.
Carlos Antonio

Reply all
Reply to author
Forward
0 new messages