Module: Authlogic::Session::Cookies::InstanceMethods

Defined in:
lib/authlogic/session/cookies.rb

Overview

The methods available for an Authlogic::Session::Base object that make up the cookie feature set.

Instance Method Summary collapse

Instance Method Details

#credentials=(value) ⇒ Object

Allows you to set the remember_me option when passing credentials.



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/authlogic/session/cookies.rb', line 55

def credentials=(value)
  super
  values = value.is_a?(Array) ? value : [value]
  case values.first
  when Hash
    self.remember_me = values.first.with_indifferent_access[:remember_me] if values.first.with_indifferent_access.key?(:remember_me)
  else
    r = values.find { |value| value.is_a?(TrueClass) || value.is_a?(FalseClass) }
    self.remember_me = r if !r.nil?
  end
end

#remember_meObject

Is the cookie going to expire after the session is over, or will it stick around?



68
69
70
71
# File 'lib/authlogic/session/cookies.rb', line 68

def remember_me
  return @remember_me if defined?(@remember_me)
  @remember_me = self.class.remember_me
end

#remember_me=(value) ⇒ Object

Accepts a boolean as a flag to remember the session or not. Basically to expire the cookie at the end of the session or keep it for “remember_me_until”.



74
75
76
# File 'lib/authlogic/session/cookies.rb', line 74

def remember_me=(value)
  @remember_me = value
end

#remember_me?Boolean

See remember_me

Returns:

  • (Boolean)


79
80
81
# File 'lib/authlogic/session/cookies.rb', line 79

def remember_me?
  remember_me == true || remember_me == "true" || remember_me == "1"
end

#remember_me_forObject

How long to remember the user if remember_me is true. This is based on the class level configuration: remember_me_for



84
85
86
87
# File 'lib/authlogic/session/cookies.rb', line 84

def remember_me_for
  return unless remember_me?
  self.class.remember_me_for
end

#remember_me_untilObject

When to expire the cookie. See remember_me_for configuration option to change this.



90
91
92
93
# File 'lib/authlogic/session/cookies.rb', line 90

def remember_me_until
  return unless remember_me?
  remember_me_for.from_now
end