1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

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

View file

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

View file

@ -54,7 +54,7 @@ module Devise
# Checks whether it's a devise mapped resource or not. # Checks whether it's a devise mapped resource or not.
def is_devise_resource? #:nodoc: 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 end
def unknown_action!(msg) 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) } Devise.mappings.each_value { |m| return m.name if duck.is_a?(m.to) }
end end
raise "Could not find a valid mapping for #{duck}" raise "Could not find a valid mapping for #{duck.inspect}"
end end
def self.find_by_path!(path, path_type=:fullpath) def self.find_by_path!(path, path_type=:fullpath)
Devise.mappings.each_value { |m| return m if path.include?(m.send(path_type)) } 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 end
def initialize(name, options) #:nodoc: def initialize(name, options) #:nodoc:

View file

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

View file

@ -119,6 +119,11 @@ class ControllerAuthenticableTest < ActionController::TestCase
@controller.sign_out(User.new) @controller.sign_out(User.new)
end 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 test 'sign out everybody proxy to logout on warden' do
@mock_warden.expects(:logout).with().returns(true) @mock_warden.expects(:logout).with().returns(true)
@controller.sign_out_all_scopes @controller.sign_out_all_scopes