Skip to content

Commit

Permalink
Merge pull request #33 from JunaidUK/customSessionTimeout
Browse files Browse the repository at this point in the history
Custom Session Reset Method
  • Loading branch information
pelargir authored Nov 11, 2021
2 parents a0f9a03 + 52bfc2a commit a07a27e
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit a07a27e

Please sign in to comment.