Module: Devision::Models::Rememberable::ClassMethods

Defined in:
lib/devision/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.



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

Recreate the user based on the stored cookie



108
109
110
111
# File 'lib/devision/models/rememberable.rb', line 108

def serialize_from_cookie(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

create a cookie key using the record id and rememberable_value



103
104
105
# File 'lib/devision/models/rememberable.rb', line 103

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