From 3791d2e90f7cd10ea98607a8e5ab21d05c32b62c Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Mon, 23 Jan 2023 21:08:11 -0600 Subject: [PATCH] Fix subdomain login --- judge/middleware.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/judge/middleware.py b/judge/middleware.py index cf2d37f..f04b708 100644 --- a/judge/middleware.py +++ b/judge/middleware.py @@ -1,5 +1,5 @@ from django.conf import settings -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect, Http404 from django.urls import Resolver404, resolve, reverse from django.utils.http import urlquote from django.contrib.sites.shortcuts import get_current_site @@ -106,10 +106,13 @@ class SubdomainMiddleware(object): and organization in request.profile.organizations.all() ): request.organization = organization - elif not request.GET.get("next", None): - return HttpResponseRedirect( - reverse("auth_login") + "?next=" + urlquote(request.path) - ) + else: + if request.profile: + raise Http404 + if not request.GET.get("next", None): + return HttpResponseRedirect( + reverse("auth_login") + "?next=" + urlquote(request.path) + ) except ObjectDoesNotExist: pass return self.get_response(request)