From c3e7a8fd7f81de9f46f6e20a224922de9469f78b Mon Sep 17 00:00:00 2001 From: Jordan Robinson Date: Sun, 14 Sep 2025 17:07:28 +0100 Subject: [PATCH] update allow for docs user if env variable --- main/middleware.py | 6 +++++- mataroa/settings.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main/middleware.py b/main/middleware.py index 4967d85020397abea90fa090c1e038c8631527be..4488631af8df951520d597e296e91b252b43b16f 100644 --- a/main/middleware.py +++ b/main/middleware.py @@ -39,8 +39,12 @@ def host_middleware(get_response): # * also validation will happen inside views request.subdomain = host_parts[0] + allow_docs_user = False + if request.subdomain == "docs" and settings.ALLOW_DOCS_USER: + allow_docs_user = True + # check if subdomain is disallowed - if request.subdomain in denylist.DISALLOWED_USERNAMES: + if request.subdomain in denylist.DISALLOWED_USERNAMES and not allow_docs_user: return redirect(f"{util.get_protocol()}//{settings.CANONICAL_HOST}") # check if subdomain exists as blog elif models.User.objects.filter(username=request.subdomain).exists(): diff --git a/mataroa/settings.py b/mataroa/settings.py index 970ebd627ea77ec73f9d5e2eb6af3c0fd9fd807a..7ed898b48092aee91504afe885ac3929239c9fe4 100644 --- a/mataroa/settings.py +++ b/mataroa/settings.py @@ -31,6 +31,8 @@ DEBUG = os.getenv("DEBUG") == "1" LOCALDEV = os.getenv("LOCALDEV") == "1" +ALLOW_DOCS_USER = os.getenv("ALLOW_DOCS_USER", "0") == "1" + ALLOWED_HOSTS = [ "127.0.0.1", "localhost",