Sha256: 7ba7aecdfc9e364526fc467e19d72ca37dd080bbdb4aa1a73b5e2de149c3297b
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
module Authlogic module Session # = Timeout # # This is reponsibile for determining if the session is stale or fresh. It is also responsible for maintaining the last_request_at value if the column is present. # # Think about how financial websites work. If you are inactive after a certain period of time you must log back in. By default this is disabled, but if enabled this # module kicks in. See the logout_on_timeout configuration option for how to turn this on. module Timeout def self.included(klass) klass.after_find :update_last_request_at! klass.after_save :update_last_request_at! end def stale? logout_on_timeout? && record && record.logged_out? end private def update_last_request_at! if record.class.column_names.include?("last_request_at") && (record.last_request_at.blank? || last_request_at_threshold.to_i.seconds.ago >= record.last_request_at) record.last_request_at = Time.now record.save_without_session_maintenance(false) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authlogic-1.3.9 | lib/authlogic/session/timeout.rb |