plataformatec/devise — Issue #1432: current_user still returning user after sign_out
Author: artemk
Created: 2011-11-09 09:36:18+00:00
State: open

sign_out method reset session and clear up warden, but Devise still holds @current_user variable which cause current_user to return user.

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.
warden.logout(scope)
p warden.user(scope) #=> nil
p @current_user #=> User
end

Let me know if this is expected behavior or a bug, i can do a patch.
Thx.