Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure route not handled #262

Closed
nbrustein opened this issue Jun 4, 2015 · 1 comment
Closed

Failure route not handled #262

nbrustein opened this issue Jun 4, 2015 · 1 comment

Comments

@nbrustein
Copy link
Contributor

I am using 'omniauth' (which I believe is the default) as my omniauth prefix:

DeviseTokenAuth.setup do |config|
   config.omniauth_prefix = "/omniauth"
end

My routes are setup at api/auth:

mount_devise_token_auth_for 'User', at: 'api/auth', controllers: {
  ...
}

If a user tries to login with facebook, but then hits "Cancel" on the screen that says "... wants access to your profile", then I get the following error:

ActionController::RoutingError: No route matches [GET] "/omniauth/failure"

Running rake routes, I can see that api/auth/failure is setup and points at the omniauth_failure action , but '/omniauth/failure' is not set up

api_auth_failure GET        /api/auth/failure(.:format)                             devise_token_auth/omniauth_callbacks#omniauth_failure

Digging into the omniauth gem, I find this code in omniauth-1.2.2/lib/omniauth/failure_endpoint.rb:

def call
  raise_out! if OmniAuth.config.failure_raise_out_environments.include?(ENV['RACK_ENV'].to_s)
  redirect_to_failure
end

...

def redirect_to_failure
  message_key = env['omniauth.error.type']
  new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}#{strategy_name_query_param}"
  Rack::Response.new(['302 Moved'], 302, 'Location' => new_path).finish
end

So it looks like omniauth is generating that /omniauth/failure path based on the value of the omniauth_prefix, but devise_token_auth is not setting that path up.

@booleanbetrayal
Copy link
Collaborator

Should be fixed via 2cac1ef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants