Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Session Reset Method #33

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/auto_session_timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def auto_session_timeout(seconds=nil)
protect_from_forgery except: [:active, :timeout]
prepend_before_action do |c|
if session_expired?(c) && !signing_in?(c)
c.send :reset_session
handle_session_reset(c)
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)
Expand Down Expand Up @@ -37,6 +37,10 @@ def render_session_timeout

private

def handle_session_reset(c)
c.send :reset_session
end

def signing_in?(c)
c.request.env["PATH_INFO"] == sign_in_path && c.request.env["REQUEST_METHOD"] == "POST"
end
Expand Down