Module: Devision::Models::Rememberable::ClassMethods
- Defined in:
- lib/devision/models/rememberable.rb
Instance Method Summary collapse
-
#remember_token ⇒ Object
Generate a token checking if one does not already exist in the database.
-
#serialize_from_cookie(id, rememberable_token_value) ⇒ Object
Recreate the user based on the stored cookie.
-
#serialize_into_cookie(record) ⇒ Object
create a cookie key using the record id and rememberable_value.
Instance Method Details
#remember_token ⇒ Object
Generate a token checking if one does not already exist in the database.
114 115 116 117 118 119 |
# File 'lib/devision/models/rememberable.rb', line 114 def remember_token #:nodoc: loop do token = Devision.nice_token break token unless to_adapter.find_first({ remember_token: token }) end end |
#serialize_from_cookie(id, rememberable_token_value) ⇒ Object
Recreate the user based on the stored cookie
108 109 110 111 |
# File 'lib/devision/models/rememberable.rb', line 108 def (id, rememberable_token_value) record = to_adapter.get(id) record if record && !record.remember_expired? && Devision.secure_compare(record.rememberable_value, rememberable_token_value) end |
#serialize_into_cookie(record) ⇒ Object
create a cookie key using the record id and rememberable_value
103 104 105 |
# File 'lib/devision/models/rememberable.rb', line 103 def (record) [record.to_key, record.rememberable_value] end |