lib/devise/models/rememberable.rb in devise-0.7.3 vs lib/devise/models/rememberable.rb in devise-0.7.4
- old
+ new
@@ -1,11 +1,9 @@
-require 'digest/sha1'
-require 'devise/serializers/rememberable'
+require 'devise/models/cookie_serializer'
module Devise
module Models
-
# Rememberable manages generating and clearing token for remember the user
# from a saved cookie. Rememberable also has utility methods for dealing
# with serializing the user into the cookie and back from the cookie, trying
# to lookup the record based on the saved information.
# You probably wouldn't use rememberable methods directly, they are used
@@ -32,11 +30,11 @@
# User.serialize_from_cookie(cookie_string)
module Rememberable
def self.included(base)
base.class_eval do
- extend ClassMethods
+ extend CookieSerializer
# Remember me option available in after_authentication hook.
attr_accessor :remember_me
end
end
@@ -69,25 +67,9 @@
end
# Remember token expires at created time + remember_for configuration
def remember_expires_at
remember_created_at + self.class.remember_for
- end
-
- module ClassMethods
- # Create the cookie key using the record id and remember_token
- def serialize_into_cookie(rememberable)
- "#{rememberable.id}::#{rememberable.remember_token}"
- end
-
- # Recreate the user based on the stored cookie
- def serialize_from_cookie(cookie)
- rememberable_id, remember_token = cookie.split('::')
- rememberable = find(:first, :conditions => { :id => rememberable_id }) if rememberable_id
- rememberable if rememberable.try(:valid_remember_token?, remember_token)
- end
-
- Devise::Models.config(self, :remember_for)
end
end
end
end