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.


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

def force_forget_me!
  config = sorcery_config
  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.


60
61
62
# File 'lib/sorcery/model/submodules/remember_me.rb', line 60

def forget_me!
  sorcery_config.remember_me_token_persist_globally || force_forget_me!
end

#has_remember_me_token?Boolean

Returns:

  • (Boolean)

54
55
56
# File 'lib/sorcery/model/submodules/remember_me.rb', line 54

def has_remember_me_token?
  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.


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

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 && has_remember_me_token?
    update_options[config.remember_me_token_attribute_name] = TemporaryToken.generate_random_token
  end

  sorcery_adapter.update_attributes(update_options)
end