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

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

Instance Method Summary collapse

Instance Method Details

#force_forget_me!Object

You shouldn't really use this one yourself - it's called by the controller's 'force_forget_me!' method.



67
68
69
70
71
# File 'lib/sorcery/model/submodules/remember_me.rb', line 67

def force_forget_me!
  config = sorcery_config
  self.sorcery_adapter.update_attributes(config.remember_me_token_attribute_name => nil,
                              config.remember_me_token_expires_at_attribute_name => nil)
end

#forget_me!Object

You shouldn't really use this one yourself - it's called by the controller's 'forget_me!' method. We only clear the token value if remember_me_token_persist_globally = true.



62
63
64
# File 'lib/sorcery/model/submodules/remember_me.rb', line 62

def forget_me!
  sorcery_config.remember_me_token_persist_globally or force_forget_me!
end

#has_remember_me_token?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/sorcery/model/submodules/remember_me.rb', line 56

def has_remember_me_token?
  self.send(sorcery_config.remember_me_token_attribute_name).present?
end

#remember_me!Object

You shouldn't really use this one yourself - it's called by the controller's 'remember_me!' method.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sorcery/model/submodules/remember_me.rb', line 44

def remember_me!
  config = sorcery_config

  update_options = { config.remember_me_token_expires_at_attribute_name => Time.now.in_time_zone + config.remember_me_for }

  unless config.remember_me_token_persist_globally and has_remember_me_token?
    update_options.merge!(config.remember_me_token_attribute_name => TemporaryToken.generate_random_token)
  end

  self.sorcery_adapter.update_attributes(update_options)
end