Skip to content

Commit

Permalink
Importing settings lazily in middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
theunraveler authored and jpic committed Apr 12, 2024
1 parent 7057066 commit de1f253
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion session_security/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
MiddlewareMixin = object

from .utils import get_last_activity, set_last_activity
from .settings import EXPIRE_AFTER, PASSIVE_URLS, PASSIVE_URL_NAMES


class SessionSecurityMiddleware(MiddlewareMixin):
Expand All @@ -35,6 +34,8 @@ class SessionSecurityMiddleware(MiddlewareMixin):

def is_passive_request(self, request):
""" Should we skip activity update on this URL/View. """
from .settings import PASSIVE_URLS, PASSIVE_URL_NAMES

if request.path in PASSIVE_URLS:
return True

Expand All @@ -50,6 +51,7 @@ def is_passive_request(self, request):

def get_expire_seconds(self, request):
"""Return time (in seconds) before the user should be logged out."""
from .settings import EXPIRE_AFTER
return EXPIRE_AFTER

def process_request(self, request):
Expand Down

0 comments on commit de1f253

Please sign in to comment.