2010-04-06 10:34:22 -04:00
|
|
|
# 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.
|
|
|
|
# This avoids forgetting deleted users.
|
2010-05-05 13:25:59 -04:00
|
|
|
Warden::Manager.before_logout do |record, warden, options|
|
2010-04-06 10:34:22 -04:00
|
|
|
if record.respond_to?(:forget_me!)
|
|
|
|
record.forget_me! unless record.frozen?
|
2010-09-25 15:13:54 -04:00
|
|
|
cookie_options = Rails.configuration.session_options.slice(:path, :domain, :secure)
|
|
|
|
cookie_options.merge!(record.cookie_options)
|
2010-09-23 22:53:43 -04:00
|
|
|
warden.cookies.delete("remember_#{options[:scope]}_token", cookie_options)
|
2010-04-06 10:34:22 -04:00
|
|
|
end
|
2010-05-05 13:25:59 -04:00
|
|
|
end
|