Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removing signed_out path workaround

  • Loading branch information...
commit 65f08ea175a2786bfca09da1e54dd203f136026e 1 parent 70b9bdc
Rodrigo Flores authored
View
5 app/controllers/devise/sessions_controller.rb
@@ -19,10 +19,9 @@ def create
# DELETE /resource/sign_out
def destroy
- signed_in = signed_in?(resource_name)
redirect_path = after_sign_out_path_for(resource_name)
- Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
- set_flash_message :notice, :signed_out if signed_in
+ signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
+ set_flash_message :notice, :signed_out if signed_out
# We actually need to hardcode this as Rails default responder doesn't
# support returning empty response on GET request
View
10 lib/devise/controllers/helpers.rb
@@ -136,19 +136,25 @@ def sign_in(resource_or_scope, *args)
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 => scope, :run_callbacks => false) # Without loading user here, before_logout hook is not called
+ return false unless warden.user(:scope => scope, :run_callbacks => false) # Without loading user here, before_logout hook is not called
+
warden.raw_session.inspect # Without this inspect here. The session does not clear.
warden.logout(scope)
instance_variable_set(:"@current_#{scope}", nil)
+ true
end
# Sign out all active users or scopes. This helper is useful for signing out all roles
# in one click. This signs out ALL scopes in warden.
def sign_out_all_scopes
- Devise.mappings.keys.each { |s| warden.user(:scope => s, :run_callbacks => false) }
+ users = Devise.mappings.keys.map { |s| warden.user(:scope => s, :run_callbacks => false) }
+
warden.raw_session.inspect
warden.logout
expire_devise_cached_variables!
+
+ return false if users.compact.empty?
+ true
end
# Returns and delete the url stored in the session for the given scope. Useful
View
7 lib/devise/hooks/timeoutable.rb
@@ -10,11 +10,8 @@
last_request_at = warden.session(scope)['last_request_at']
if record.timedout?(last_request_at)
- path_checker = Devise::PathChecker.new(warden.env, scope)
- unless path_checker.signing_out?
- warden.logout(scope)
- throw :warden, :scope => scope, :message => :timeout
- end
+ warden.logout(scope)
+ throw :warden, :scope => scope, :message => :timeout
end
unless warden.request.env['devise.skip_trackable']
View
2  test/integration/timeoutable_test.rb
@@ -50,10 +50,12 @@ def last_request_at
get expire_user_path(user)
get destroy_user_session_path
+
assert_response :redirect
assert_redirected_to root_path
follow_redirect!
+
assert_contain 'Signed out successfully'
end
View
2  test/rails_app/app/controllers/application_controller.rb
@@ -3,6 +3,6 @@
class ApplicationController < ActionController::Base
protect_from_forgery
- before_filter :current_user
+ before_filter :current_user, :unless => :devise_controller?
before_filter :authenticate_user!, :if => :devise_controller?
end

0 comments on commit 65f08ea

Please sign in to comment.
Something went wrong with that request. Please try again.