Module: Sorcery::Controller::Submodules::SessionTimeout

Defined in:
lib/sorcery/controller/submodules/session_timeout.rb

Overview

This submodule helps you set a timeout to all user sessions. The timeout can be configured and also you can choose to reset it on every user action.

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sorcery/controller/submodules/session_timeout.rb', line 7

def self.included(base)
  base.send(:include, InstanceMethods)
  Config.module_eval do
    class << self
      attr_accessor :session_timeout,                     # how long in seconds to keep the session alive.

                    :session_timeout_from_last_action     # use the last action as the beginning of session
                                                          # timeout.

      def merge_session_timeout_defaults!
        @defaults.merge!(:@session_timeout                      => 3600, # 1.hour
                         :@session_timeout_from_last_action     => false)
      end
    end
    merge_session_timeout_defaults!
  end
  Config. << :register_login_time
  base.prepend_before_filter :validate_session
end