8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/auto_session_timeout.rb', line 8
def auto_session_timeout(seconds=nil, sign_in_path)
prepend_before_action do |c|
if c.session[:auto_session_expires_at] && c.session[:auto_session_expires_at] < Time.now && (sign_in_path ? !(c.env["PATH_INFO"] == sign_in_path && c.env["REQUEST_METHOD"] == "POST") : true)
c.send :reset_session
else
unless c.request.original_url.start_with?(c.send(:active_url))
offset = seconds || (current_user.respond_to?(:auto_timeout) ? current_user.auto_timeout : nil)
c.session[:auto_session_expires_at] = Time.now + offset if offset && offset > 0
end
end
end
end
|