mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-28 03:00:29 -04:00
support multiple warden configuration blocks
Changes the behavior of `Devise.warden` such that calling it multiple times with different blocks will result in a call to each block on `Devise.configure_warden!` rather than "last block wins". This is especially used for plugins that wish to extend warden functionality without clobbering base app configuration or vice versa.
This commit is contained in:
@@ -272,7 +272,7 @@ module Devise
|
||||
# Private methods to interface with Warden.
|
||||
mattr_accessor :warden_config
|
||||
@@warden_config = nil
|
||||
@@warden_config_block = nil
|
||||
@@warden_config_blocks = []
|
||||
|
||||
# When true, enter in paranoid mode to avoid user enumeration.
|
||||
mattr_accessor :paranoid
|
||||
@@ -413,7 +413,7 @@ module Devise
|
||||
# end
|
||||
# end
|
||||
def self.warden(&block)
|
||||
@@warden_config_block = block
|
||||
@@warden_config_blocks << block
|
||||
end
|
||||
|
||||
# Specify an omniauth provider.
|
||||
@@ -467,7 +467,7 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
@@warden_config_block.try :call, Devise.warden_config
|
||||
@@warden_config_blocks.map { |block| block.call Devise.warden_config }
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user