fix auto-login debugging middleware to only apply to localhost or 127.0.0.1

This commit is contained in:
badblocks 2025-02-26 17:05:36 -08:00
parent 71b3993326
commit 80da7be559

View file

@ -11,7 +11,7 @@ class AutoLoginMiddleware:
def __call__(self, request): def __call__(self, request):
# Only perform auto-login if in DEBUG mode and user is not authenticated. # Only perform auto-login if in DEBUG mode and user is not authenticated.
if settings.DEBUG and not request.user.is_authenticated: if settings.DEBUG and not request.user.is_authenticated and request.host in ['pocket-trade.fly.dev', 'localhost', '127.0.0.1']:
user = CustomUser.objects.get(email='rob@badblocks.email') user = CustomUser.objects.get(email='rob@badblocks.email')
login(request, user, backend='django.contrib.auth.backends.ModelBackend') login(request, user, backend='django.contrib.auth.backends.ModelBackend')