From e26c8ce499324073058b43b31571c08a4c68acd4 Mon Sep 17 00:00:00 2001 From: Chase DuBois Date: Thu, 21 Apr 2011 23:29:15 +0800 Subject: [PATCH] Use #persisted? instead of #frozen? to check whether #forget_me should attempt to clear remember token from database --- lib/devise/controllers/rememberable.rb | 2 +- lib/devise/hooks/forgetable.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/devise/controllers/rememberable.rb b/lib/devise/controllers/rememberable.rb index 44415a3d..e9fde72a 100644 --- a/lib/devise/controllers/rememberable.rb +++ b/lib/devise/controllers/rememberable.rb @@ -29,7 +29,7 @@ module Devise # Forgets the given resource by deleting a cookie def forget_me(resource) scope = Devise::Mapping.find_scope!(resource) - resource.forget_me! unless resource.frozen? + resource.forget_me! unless !resource.persisted? cookies.delete("remember_#{scope}_token", forget_cookie_values(resource)) end diff --git a/lib/devise/hooks/forgetable.rb b/lib/devise/hooks/forgetable.rb index 3678bcb7..bf0374f4 100644 --- a/lib/devise/hooks/forgetable.rb +++ b/lib/devise/hooks/forgetable.rb @@ -1,6 +1,6 @@ # Before logout hook to forget the user in the given scope, if it responds # to forget_me! Also clear remember token to ensure the user won't be -# remembered again. Notice that we forget the user unless the record is frozen. +# remembered again. Notice that we forget the user unless the record is not persisted. # This avoids forgetting deleted users. Warden::Manager.before_logout do |record, warden, options| if record.respond_to?(:forget_me!)