Skip to content

Commit

Permalink
anybody_signed_in? helper
Browse files Browse the repository at this point in the history
  • Loading branch information
SSDany authored and josevalim committed Jun 12, 2010
1 parent 0609a5e commit 55a4712
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/devise/controllers/helpers.rb
Expand Up @@ -48,6 +48,12 @@ def signed_in?(scope)
warden.authenticate?(:scope => scope)
end

# Check if the any scope is signed in session, without running
# authentication hooks.
def anybody_signed_in?
Devise.mappings.keys.any? { |scope| signed_in?(scope) }
end

# Sign in an user that already was authenticated. This helper is useful for logging
# users in after sign up.
#
Expand Down
7 changes: 7 additions & 0 deletions test/controllers/helpers_test.rb
Expand Up @@ -36,6 +36,13 @@ def setup
@controller.signed_in?(:my_scope)
end

test 'proxy anybody_signed_in? to signed_in?' do
Devise.mappings.keys.each { |scope| # :user, :admin, :manager
@controller.expects(:signed_in?).with(scope)
}
@controller.anybody_signed_in?
end

test 'proxy current_admin to authenticate with admin scope' do
@mock_warden.expects(:authenticate).with(:scope => :admin)
@controller.current_admin
Expand Down

0 comments on commit 55a4712

Please sign in to comment.