Sha256: 188e5efa46d8528133c50196f5b08c176cf822b4030e4436623bd5995626597a

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'devise/hooks/timeoutable'

module Devise
  module Models
    # Timeoutable takes care of verifying whether a user session has already
    # expired or not. When a session expires after the configured time, the user
    # will be asked for credentials again, it means, they will be redirected
    # to the sign in page.
    #
    # == Options
    #
    # Timeoutable adds the following options to +devise+:
    #
    #   * +timeout_in+: the interval to timeout the user session without activity.
    #
    # == Examples
    #
    #   user.timedout?(30.minutes.ago)
    #
    module Timeoutable
      extend ActiveSupport::Concern

      def self.required_fields(klass)
        []
      end

      # Checks whether the user session has expired based on configured time.
      def timedout?(last_access)
        !timeout_in.nil? && last_access && last_access <= timeout_in.ago
      end

      def timeout_in
        self.class.timeout_in
      end

      private

      module ClassMethods
        Devise::Models.config(self, :timeout_in)
      end
    end
  end
end

Version data entries

9 entries across 8 versions & 3 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/devise-4.9.4/lib/devise/models/timeoutable.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/devise-4.9.4/lib/devise/models/timeoutable.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/devise-4.9.4/lib/devise/models/timeoutable.rb
devise-4.9.4 lib/devise/models/timeoutable.rb
devise-4.9.3 lib/devise/models/timeoutable.rb
devise-4.9.2 lib/devise/models/timeoutable.rb
devise-4.9.1 lib/devise/models/timeoutable.rb
devise-4.9.0 lib/devise/models/timeoutable.rb
devise-4.8.1 lib/devise/models/timeoutable.rb