Smallish updates.

This commit is contained in:
José Valim 2010-11-11 13:53:52 +01:00
parent 2d2c4c63be
commit b2496d1bc1
6 changed files with 14 additions and 11 deletions

View File

@ -4,7 +4,7 @@ PATH
devise (1.2.rc)
bcrypt-ruby (~> 2.1.2)
orm_adapter (~> 0.0.2)
warden (~> 1.0.0)
warden (~> 1.0.2)
GEM
remote: http://rubygems.org/
@ -158,5 +158,5 @@ DEPENDENCIES
rails
ruby-debug (>= 0.10.3)
sqlite3-ruby
warden (~> 1.0.0)
warden (~> 1.0.2)
webrat (= 0.7.1)

View File

@ -121,7 +121,8 @@ module Devise
# sign_out :user # sign_out(scope)
# sign_out @user # sign_out(resource)
#
def sign_out(resource_or_scope)
def sign_out(resource_or_scope=nil)
return sign_out_all_scopes unless resource_or_scope
scope = Devise::Mapping.find_scope!(resource_or_scope)
warden.user(scope) # Without loading user here, before_logout hook is not called
warden.raw_session.inspect # Without this inspect here. The session does not clear.
@ -214,11 +215,7 @@ module Devise
# after_sign_out_path_for.
def sign_out_and_redirect(resource_or_scope)
scope = Devise::Mapping.find_scope!(resource_or_scope)
if Devise.sign_out_all_scopes
sign_out_all_scopes
else
sign_out(scope)
end
Devise.sign_out_all_scopes ? sign_out : sign_out(scope)
redirect_for_sign_out(scope)
end

View File

@ -54,7 +54,7 @@ module Devise
# Checks whether it's a devise mapped resource or not.
def is_devise_resource? #:nodoc:
unknown_action!("Could not find devise mapping for #{request.fullpath}.") unless devise_mapping
unknown_action!("Could not find devise mapping for path #{request.fullpath.inspect}") unless devise_mapping
end
def unknown_action!(msg)

View File

@ -37,12 +37,12 @@ module Devise
Devise.mappings.each_value { |m| return m.name if duck.is_a?(m.to) }
end
raise "Could not find a valid mapping for #{duck}"
raise "Could not find a valid mapping for #{duck.inspect}"
end
def self.find_by_path!(path, path_type=:fullpath)
Devise.mappings.each_value { |m| return m if path.include?(m.send(path_type)) }
raise "Could not find a valid mapping for path #{path}"
raise "Could not find a valid mapping for path #{path.inspect}"
end
def initialize(name, options) #:nodoc:

View File

@ -3,6 +3,7 @@ module Warden::Mixins::Common
@request ||= ActionDispatch::Request.new(env)
end
# This is called internally by Warden on logout
def reset_session!
request.reset_session
end

View File

@ -119,6 +119,11 @@ class ControllerAuthenticableTest < ActionController::TestCase
@controller.sign_out(User.new)
end
test 'sign out without args proxy to sign out all scopes' do
@mock_warden.expects(:logout).with().returns(true)
@controller.sign_out
end
test 'sign out everybody proxy to logout on warden' do
@mock_warden.expects(:logout).with().returns(true)
@controller.sign_out_all_scopes