Can someone help me deal with this issue?
I am using Devise + Omniauth in a Rails 3.2 application. I want to know what happens behind the scenes using the Devise method user_omniauth_authorize_path(provider)
.
I had digging through rake routes and a source of gems, but I see nothing obvious that could cause a problem that I am facing.
I assume that this method simply calls the provider subscriber URL (e.g. Twitter) and then returns to the callback path defined in route.rb.
On my routes .rb I have
devise_for :users, :controllers => { :omniauth_callbacks => 'users/omniauth_callbacks'} devise_scope :user do get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' end
Users / omniauth _callbacks_controller.rb I have
def twitter render :text => "This works" end def passthru render :text => "This doesn't work" end
In the view, I have <%= link_to "Twitter", user_omniauth_authorize_path(:twitter) %>
. By clicking on this link, you will go to Twitter, where I can log in, but after returning to my application I get an error message "You are already logged in".
I cannot understand how and why this error is generated. I should see only โIt worksโ or โIt does not workโ.
I also have a Facebook provider installed exactly as expected.
If I replace the Devise omniauth link with <a href="/users/auth/twitter">Twitter</a>
, then I get "It works."
So this solves my problem, but it is not perfect, and I would like to know why.
Can anyone shed some light?
EDIT
Route routes are as follows:
user_omniauth_callback /users/auth/:action/callback(.:format) users/omniauth_callbacks