Only add sessions refresh data to existing sessions

Prior to change session were created for _every_ request (including API
requests).
This commit is contained in:
Christopher C. Wells 2021-08-05 06:34:08 -07:00
parent 207a5bc236
commit f29269869c
1 changed files with 12 additions and 11 deletions

View File

@ -26,12 +26,13 @@ class UserTimezoneMiddleware:
class RollingSessionMiddleware:
"""
Periodically resets the session expiry.
Periodically resets the session expiry for existing sessions.
"""
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if request.session.keys():
session_refresh = request.session.get('session_refresh')
if session_refresh:
try: