Merge pull request #2366 from TracksApp/fix-expiry-check

Parse the session time so we can calculate expire time.
This commit is contained in:
Matt Rogers 2020-03-29 10:24:05 -05:00 committed by GitHub
commit 772b68b0c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,7 +40,6 @@ class LoginController < ApplicationController
if session if session
return unless should_expire_sessions? return unless should_expire_sessions?
# Get expiry time (allow ten seconds window for the case where we have none) # Get expiry time (allow ten seconds window for the case where we have none)
expiry_time = session['expiry_time'] || Time.now + 10
time_left = expiry_time - Time.now time_left = expiry_time - Time.now
@session_expired = ( time_left < (10*60) ) # Session will time out before the next check @session_expired = ( time_left < (10*60) ) # Session will time out before the next check
end end
@ -76,4 +75,9 @@ class LoginController < ApplicationController
session['noexpiry'] != "on" session['noexpiry'] != "on"
end end
def expiry_time
return Time.now + 10 unless session['expiry_time']
DateTime.strptime(session['expiry_time'], "%FT%T%Z")
end
end end