From 939010d09a4186e0bd9300d21b0a22880b44e125 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Mon, 22 Jan 2018 17:02:11 -0800 Subject: [PATCH] Remove local var `devise_mapping`; use the overridden `#devise_mapping` instead. Instead of re-inventing `devise_mapping`, just use the overridden method that is inherited from `DeviseController` in the `Devise` gem. The override takes the `omniauth_params` into account, if there are any. --- .../devise_token_auth/omniauth_callbacks_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index a9dd78c16..af7a905a0 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -11,9 +11,7 @@ def redirect_callbacks # derive target redirect route from 'resource_class' param, which was set # before authentication. - devise_mapping = [request.env['omniauth.params']['namespace_name'], - request.env['omniauth.params']['resource_class'].underscore.gsub('/', '_')].compact.join('_') - path = "#{Devise.mappings[devise_mapping.to_sym].fullpath}/#{params[:provider]}/callback" + path = "#{devise_mapping.fullpath}/#{params[:provider]}/callback" klass = request.scheme == 'https' ? URI::HTTPS : URI::HTTP redirect_route = klass.build(host: request.host, port: request.port, path: path).to_s