Sha256: 4cefa39aba9c6c52148e92f7eda64c8cb8802e3871a45ac20d38c11e684de43c
Contents?: true
Size: 992 Bytes
Versions: 5
Compression:
Stored size: 992 Bytes
Contents
# frozen_string_literal: true module Omniauth module Rails class AuthenticationSession EMAIL_KEY = "email" EXPIRE_AT_KEY = "expire_at" def initialize(session) @session = session reset if expired? freeze end delegate :reset, to: :data_store def authenticated? email.present? end def email data_store.get(EMAIL_KEY) end def email=(email) data_store.set(EMAIL_KEY, email) end def expire_in(duration) self.expire_at = (Time.now.to_i + duration) end def expire_at data_store.get(EXPIRE_AT_KEY) end def expire_at=(expire_at) data_store.set(EXPIRE_AT_KEY, expire_at) end private attr_reader :session def data_store @data_store ||= AuthenticationDataStore.new(session) end def expired? expire_at.present? && expire_at < Time.now.to_i end end end end
Version data entries
5 entries across 5 versions & 1 rubygems