diff --git a/lib/devise/controllers/helpers.rb b/lib/devise/controllers/helpers.rb index a53469a5..5d3e908c 100644 --- a/lib/devise/controllers/helpers.rb +++ b/lib/devise/controllers/helpers.rb @@ -258,6 +258,10 @@ module Devise end def expire_session_data_after_sign_in! + # session.keys will return an empty array if the session is not yet loaded. + # This is a bug in both Rack and Rails. + # A call to #empty? forces the session to be loaded. + session.empty? session.keys.grep(/^devise\./).each { |k| session.delete(k) } end