mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Fix warden configuration.
This commit is contained in:
parent
1d65a76cf3
commit
3d1a04fd83
5 changed files with 11 additions and 20 deletions
|
@ -230,12 +230,8 @@ module Devise
|
||||||
|
|
||||||
# A method used internally to setup warden manager from the Rails initialize
|
# A method used internally to setup warden manager from the Rails initialize
|
||||||
# block.
|
# block.
|
||||||
def self.configure_warden(config) #:nodoc:
|
def self.configure_warden! #:nodoc:
|
||||||
config.failure_app = Devise::FailureApp
|
@@warden_config_block.try :call, Devise.warden_config
|
||||||
config.default_scope = Devise.default_scope
|
|
||||||
|
|
||||||
@@warden_config = config
|
|
||||||
@@warden_config_block.try :call, config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate a friendly string randomically to be used as token.
|
# Generate a friendly string randomically to be used as token.
|
||||||
|
|
|
@ -7,7 +7,9 @@ module Devise
|
||||||
|
|
||||||
initializer "devise.add_middleware" do |app|
|
initializer "devise.add_middleware" do |app|
|
||||||
app.config.middleware.use Warden::Manager do |config|
|
app.config.middleware.use Warden::Manager do |config|
|
||||||
Devise.configure_warden(config)
|
Devise.warden_config = config
|
||||||
|
config.failure_app = Devise::FailureApp
|
||||||
|
config.default_scope = Devise.default_scope
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,9 @@ 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!
|
||||||
return if Devise.mappings.empty?
|
Devise.configure_warden!
|
||||||
|
|
||||||
ActionController::Base.send :include, Devise::Controllers::Helpers
|
ActionController::Base.send :include, Devise::Controllers::Helpers
|
||||||
ActionController::Base.send :include, Devise::Controllers::UrlHelpers
|
ActionController::Base.send :include, Devise::Controllers::UrlHelpers
|
||||||
|
|
||||||
ActionView::Base.send :include, Devise::Controllers::UrlHelpers
|
ActionView::Base.send :include, Devise::Controllers::UrlHelpers
|
||||||
end
|
end
|
||||||
alias_method_chain :finalize!, :devise
|
alias_method_chain :finalize!, :devise
|
||||||
|
|
|
@ -108,6 +108,6 @@ Devise.setup do |config|
|
||||||
# twitter.consumer_key = <YOUR CONSUMER KEY>
|
# twitter.consumer_key = <YOUR CONSUMER KEY>
|
||||||
# twitter.options :site => 'http://twitter.com'
|
# twitter.options :site => 'http://twitter.com'
|
||||||
# end
|
# end
|
||||||
# manager.default_strategies.unshift :twitter_oauth
|
# manager.default_strategies(:scope => :user).unshift :twitter_oauth
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,14 +23,9 @@ class DeviseTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'warden manager configuration' do
|
test 'stores warden configuration' do
|
||||||
Devise.yield_and_restore do
|
assert_equal Devise::FailureApp, Devise.warden_config.failure_app
|
||||||
config = Warden::Config.new
|
assert_equal :user, Devise.warden_config.default_scope
|
||||||
Devise.configure_warden(config)
|
|
||||||
|
|
||||||
assert_equal Devise::FailureApp, config.failure_app
|
|
||||||
assert_equal :user, config.default_scope
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'warden manager user configuration through a block' do
|
test 'warden manager user configuration through a block' do
|
||||||
|
@ -41,7 +36,7 @@ class DeviseTest < ActiveSupport::TestCase
|
||||||
assert_kind_of Warden::Config, config
|
assert_kind_of Warden::Config, config
|
||||||
end
|
end
|
||||||
|
|
||||||
Devise.configure_warden(Warden::Config.new)
|
Devise.configure_warden!
|
||||||
assert @executed
|
assert @executed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue