Module: Sorcery::Model::Submodules::RememberMe

Defined in:
lib/sorcery/model/submodules/remember_me.rb

Overview

The Remember Me submodule takes care of setting the user’s cookie so that he will be automatically logged in to the site on every visit, until the cookie expires.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sorcery/model/submodules/remember_me.rb', line 8

def self.included(base)
  base.sorcery_config.class_eval do
    attr_accessor :remember_me_token_attribute_name,              # the attribute in the model class.
                  :remember_me_token_expires_at_attribute_name,   # the expires attribute in the model class.
                  :remember_me_token_persist_globally,            # persist a single token globally for all logins/logouts (supporting multiple simultaneous browsers)
                  :remember_me_for                                # how long in seconds to remember.
  end

  base.sorcery_config.instance_eval do
    @defaults.merge!(:@remember_me_token_attribute_name            => :remember_me_token,
                     :@remember_me_token_expires_at_attribute_name => :remember_me_token_expires_at,
                     :@remember_me_token_persist_globally          => false,
                     :@remember_me_for                             => 7 * 60 * 60 * 24)

    reset!
  end

  base.send(:include, InstanceMethods)
  base.sorcery_config.after_config << :define_remember_me_fields

  base.extend(ClassMethods)
end