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 26 27 28 29 30 31 |
# File 'lib/sorcery/controller/submodules/session_timeout.rb', line 7 def self.included(base) base.send(:include, InstanceMethods) Config.module_eval do class << self # how long in seconds to keep the session alive. attr_accessor :session_timeout # use the last action as the beginning of session timeout. attr_accessor :session_timeout_from_last_action # allow users to invalidate active sessions attr_accessor :session_timeout_invalidate_active_sessions_enabled def merge_session_timeout_defaults! @defaults.merge!(:@session_timeout => 3600, # 1.hour :@session_timeout_from_last_action => false, :@session_timeout_invalidate_active_sessions_enabled => false) end end merge_session_timeout_defaults! end Config.after_login << :register_login_time Config.after_remember_me << :register_login_time base.prepend_before_action :validate_session end |