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

Use #persisted? instead of #frozen? to check whether #forget_me should attempt to clear remember token from database

This commit is contained in:
Chase DuBois 2011-04-21 23:29:15 +08:00 committed by José Valim
parent 64cf8a4534
commit e26c8ce499
2 changed files with 2 additions and 2 deletions

View file

@ -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

View file

@ -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!)