diff --git a/lib/devise.rb b/lib/devise.rb index c064b223..713c5c7e 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -199,6 +199,11 @@ module Devise # to provide custom routes. mattr_accessor :router_name @@router_name = nil + + # Set the omniauth path prefix so it can be overriden when + # Devise is used in a mountable engine + mattr_accessor :omniauth_path_prefix + @@omniauth_path_prefix = nil def self.encryptor=(value) warn "\n[DEVISE] To select a encryption which isn't bcrypt, you should use devise-encryptable gem.\n" diff --git a/lib/devise/rails/routes.rb b/lib/devise/rails/routes.rb index 9eada5a4..0125a1ec 100644 --- a/lib/devise/rails/routes.rb +++ b/lib/devise/rails/routes.rb @@ -382,7 +382,7 @@ module ActionDispatch::Routing def devise_omniauth_callback(mapping, controllers) #:nodoc: path, @scope[:path] = @scope[:path], nil - path_prefix = "/#{mapping.path}/auth".squeeze("/") + path_prefix = Devise.omniauth_path_prefix || "/#{mapping.path}/auth".squeeze("/") set_omniauth_path_prefix!(path_prefix) match "#{path_prefix}/:action/callback", :constraints => { :action => Regexp.union(mapping.to.omniauth_providers.map(&:to_s)) },