Module: Devise::Models::Rememberable::ClassMethods

Defined in:
lib/devise/models/rememberable.rb

Instance Method Summary collapse

Instance Method Details

#remember_tokenObject

Generate a token checking if one does not already exist in the database.



122
123
124
125
126
127
# File 'lib/devise/models/rememberable.rb', line 122

def remember_token #:nodoc:
  loop do
    token = Devise.friendly_token
    break token unless to_adapter.find_first({ remember_token: token })
  end
end

Recreate the user based on the stored cookie



112
113
114
# File 'lib/devise/models/rememberable.rb', line 112

def serialize_from_cookie(*args)
  serialize_from_cookie_with_or_without_record(nil, args)
end

Create the cookie key using the record id and remember_token



107
108
109
# File 'lib/devise/models/rememberable.rb', line 107

def serialize_into_cookie(record)
  [record.to_key, record.rememberable_value, Time.now.utc]
end

#serialized_in_cookie?(record, *args) ⇒ Boolean

Check if the given record is the one serialized in cookie

Returns:

  • (Boolean)


117
118
119
# File 'lib/devise/models/rememberable.rb', line 117

def serialized_in_cookie?(record, *args)
  !!serialize_from_cookie_with_or_without_record(record, args)
end