class Authlogic::CookieCredentials

Represents the credentials in the cookie. The value of the cookie. This is primarily a data object. It doesn't interact with controllers. It doesn't know about eg. cookie expiration.

@api private

Constants

DELIMITER

Attributes

persistence_token[R]
record_id[R]
remember_me_until[R]

Public Class Methods

new(persistence_token, record_id, remember_me_until) click to toggle source

@api private @param persistence_token [String] @param record_id [String, Numeric] @param remember_me_until [ActiveSupport::TimeWithZone]

# File lib/authlogic/cookie_credentials.rb, line 22
def initialize(persistence_token, record_id, remember_me_until)
  @persistence_token = persistence_token
  @record_id = record_id
  @remember_me_until = remember_me_until
end
parse(string) click to toggle source

@api private

# File lib/authlogic/cookie_credentials.rb, line 30
def parse(string)
  parts = string.split(DELIMITER)
  unless (1..3).cover?(parts.length)
    raise ParseError, format("Expected 1..3 parts, got %d", parts.length)
  end
  new(parts[0], parts[1], parse_time(parts[2]))
end

Private Class Methods

parse_time(string) click to toggle source

@api private

# File lib/authlogic/cookie_credentials.rb, line 41
def parse_time(string)
  return if string.nil?
  ::Time.parse(string)
rescue ::ArgumentError => e
  raise ParseError, format("Found cookie, cannot parse remember_me_until: #{e}")
end

Public Instance Methods

remember_me?() click to toggle source

@api private

# File lib/authlogic/cookie_credentials.rb, line 50
def remember_me?
  !@remember_me_until.nil?
end
to_s() click to toggle source

@api private

# File lib/authlogic/cookie_credentials.rb, line 55
def to_s
  [
    @persistence_token,
    @record_id.to_s,
    @remember_me_until&.iso8601
  ].compact.join(DELIMITER)
end