mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Fix an issue causing infinite redirects in production, closes #720
This commit is contained in:
parent
b942520dc4
commit
a156576ce9
4 changed files with 35 additions and 2 deletions
|
@ -204,6 +204,11 @@ module Devise
|
||||||
@@warden_config = nil
|
@@warden_config = nil
|
||||||
@@warden_config_block = nil
|
@@warden_config_block = nil
|
||||||
|
|
||||||
|
# Store whether the route file was already loaded.
|
||||||
|
mattr_accessor :routes_loaded
|
||||||
|
@@routes_loaded = false
|
||||||
|
@@routes_prepare = []
|
||||||
|
|
||||||
# Default way to setup Devise. Run rails generate devise_install to create
|
# Default way to setup Devise. Run rails generate devise_install to create
|
||||||
# a fresh initializer with all configuration values.
|
# a fresh initializer with all configuration values.
|
||||||
def self.setup
|
def self.setup
|
||||||
|
@ -359,6 +364,25 @@ module Devise
|
||||||
def self.friendly_token
|
def self.friendly_token
|
||||||
ActiveSupport::SecureRandom.base64(44).tr('+/=', 'xyz')
|
ActiveSupport::SecureRandom.base64(44).tr('+/=', 'xyz')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Store a block to be executed only after the routes are loaded.
|
||||||
|
# Required on config.cache_classes environment as a class may be
|
||||||
|
# loaded to early and then some configuration wouldn't apply.
|
||||||
|
def self.routes_prepare
|
||||||
|
if Rails.application.config.cache_classes || !routes_loaded
|
||||||
|
@@routes_prepare << Proc.new
|
||||||
|
else
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Invoke the stored routes prepare blocks and set routes_loaded to true.
|
||||||
|
def self.call_routes_prepare!
|
||||||
|
while block = @@routes_prepare.shift
|
||||||
|
block.call
|
||||||
|
end
|
||||||
|
@routes_loaded = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'warden'
|
require 'warden'
|
||||||
|
|
|
@ -16,12 +16,15 @@ module Devise
|
||||||
helper_method *helpers
|
helper_method *helpers
|
||||||
|
|
||||||
prepend_before_filter :is_devise_resource?
|
prepend_before_filter :is_devise_resource?
|
||||||
skip_before_filter *Devise.mappings.keys.map { |m| :"authenticate_#{m}!" }
|
|
||||||
|
Devise.routes_prepare do
|
||||||
|
skip_before_filter *Devise.mappings.keys.map { |m| :"authenticate_#{m}!" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gets the actual resource stored in the instance variable
|
# Gets the actual resource stored in the instance variable
|
||||||
def resource
|
def resource
|
||||||
instance_variable_get(:"@#{resource_name}")
|
instance_variable_get("@#{resource_name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Proxy to devise map name
|
# Proxy to devise map name
|
||||||
|
|
|
@ -4,6 +4,7 @@ module ActionDispatch::Routing
|
||||||
# need devise_for mappings already declared to create filters and helpers.
|
# need devise_for mappings already declared to create filters and helpers.
|
||||||
def finalize_with_devise!
|
def finalize_with_devise!
|
||||||
finalize_without_devise!
|
finalize_without_devise!
|
||||||
|
Devise.call_routes_prepare!
|
||||||
Devise.configure_warden!
|
Devise.configure_warden!
|
||||||
end
|
end
|
||||||
alias_method_chain :finalize!, :devise
|
alias_method_chain :finalize!, :devise
|
||||||
|
|
|
@ -31,5 +31,10 @@ module RailsApp
|
||||||
config.filter_parameters << :password
|
config.filter_parameters << :password
|
||||||
|
|
||||||
config.action_mailer.default_url_options = { :host => "localhost:3000" }
|
config.action_mailer.default_url_options = { :host => "localhost:3000" }
|
||||||
|
|
||||||
|
# This was used to break devise in some situations
|
||||||
|
config.to_prepare do
|
||||||
|
Devise::SessionsController.layout "application"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue