2022-08-14 11:35:03 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.contrib.auth.middleware import RemoteUserMiddleware
|
|
|
|
|
2023-08-14 22:20:52 +00:00
|
|
|
from bookmarks.models import UserProfile
|
|
|
|
|
2022-08-14 11:35:03 +00:00
|
|
|
|
|
|
|
class CustomRemoteUserMiddleware(RemoteUserMiddleware):
|
|
|
|
header = settings.LD_AUTH_PROXY_USERNAME_HEADER
|
2023-08-14 22:20:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserProfileMiddleware:
|
|
|
|
def __init__(self, get_response):
|
|
|
|
self.get_response = get_response
|
|
|
|
|
|
|
|
def __call__(self, request):
|
|
|
|
if request.user.is_authenticated:
|
|
|
|
request.user_profile = request.user.profile
|
|
|
|
else:
|
|
|
|
request.user_profile = UserProfile()
|
|
|
|
request.user_profile.enable_favicons = True
|
|
|
|
|
|
|
|
response = self.get_response(request)
|
|
|
|
|
|
|
|
return response
|