Files
Django-Proxmox-Mikrotik/frontend/middleware.py

18 lines
602 B
Python
Raw Normal View History

2025-08-27 09:55:55 +02:00
from django.conf import settings
2025-09-04 09:52:23 +02:00
from django_proxmox_mikrotik.settings import ADMIN_BASE_URL
2025-08-27 09:55:55 +02:00
class FrontendSessionMiddleware:
def __init__(self, get_response):
self.get_response = get_response
self.default_session_cookie_name = 'sessionid'
def __call__(self, request):
2025-09-04 09:52:23 +02:00
if not request.path.startswith(ADMIN_BASE_URL):
2025-08-27 09:55:55 +02:00
settings.SESSION_COOKIE_NAME = settings.SESSION_COOKIE_NAME_FRONTEND
else:
settings.SESSION_COOKIE_NAME = self.default_session_cookie_name
response = self.get_response(request)
return response