Deprecate anybody_signed_in? in favor of signed_in?(nil)
This commit is contained in:
parent
1d6944d201
commit
fe5ef25614
|
@ -72,16 +72,18 @@ module Devise
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if the given scope is signed in session, without running
|
# Return true if the given scope is signed in session. If no scope given, return
|
||||||
# authentication hooks.
|
# true if any scope is signed in. Does not run authentication hooks.
|
||||||
def signed_in?(scope)
|
def signed_in?(scope=nil)
|
||||||
warden.authenticate?(:scope => scope)
|
[ scope || Devise.mappings.keys ].flatten.any? do |scope|
|
||||||
|
warden.authenticate?(:scope => scope)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if the any scope is signed in session, without running
|
|
||||||
# authentication hooks.
|
|
||||||
def anybody_signed_in?
|
def anybody_signed_in?
|
||||||
Devise.mappings.keys.any? { |scope| signed_in?(scope) }
|
ActiveSupport::Deprecation.warn "Devise#anybody_signed_in? is deprecated. "
|
||||||
|
"Please use Devise#signed_in?(nil) instead."
|
||||||
|
signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sign in an user that already was authenticated. This helper is useful for logging
|
# Sign in an user that already was authenticated. This helper is useful for logging
|
||||||
|
|
|
@ -13,16 +13,16 @@ class ControllerAuthenticableTest < ActionController::TestCase
|
||||||
assert_equal @mock_warden, @controller.warden
|
assert_equal @mock_warden, @controller.warden
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'proxy signed_in? to authenticated' do
|
test 'proxy signed_in?(scope) to authenticate?' do
|
||||||
@mock_warden.expects(:authenticate?).with(:scope => :my_scope)
|
@mock_warden.expects(:authenticate?).with(:scope => :my_scope)
|
||||||
@controller.signed_in?(:my_scope)
|
@controller.signed_in?(:my_scope)
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'proxy anybody_signed_in? to signed_in?' do
|
test 'proxy signed_in?(nil) to authenticate?' do
|
||||||
Devise.mappings.keys.each do |scope| # :user, :admin, :manager
|
Devise.mappings.keys.each do |scope| # :user, :admin, :manager
|
||||||
@controller.expects(:signed_in?).with(scope)
|
@mock_warden.expects(:authenticate?).with(:scope => scope)
|
||||||
end
|
end
|
||||||
@controller.anybody_signed_in?
|
@controller.signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'proxy current_user to authenticate with user scope' do
|
test 'proxy current_user to authenticate with user scope' do
|
||||||
|
|
Loading…
Reference in New Issue