Sha256: f72d633776ddb4206b9b0ba1a25369b4258b3447f6fbc27a2833a2960cc39384

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 Bytes

Contents

require 'devise/hooks/timeoutable'

module Devise
  module Models

    # Timeoutable takes care of veryfing 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, he/she will be redirected
    # to the sign in page.
    #
    # Configuration:
    #
    #   timeout: the time you want to timeout the user session without activity.
    module Timeoutable
      def self.included(base)
        base.extend ClassMethods
      end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise-0.8.2 lib/devise/models/timeoutable.rb
devise-0.8.1 lib/devise/models/timeoutable.rb
devise-0.8.0 lib/devise/models/timeoutable.rb