~linuxgoose/bocpress

c3e7a8fd7f81de9f46f6e20a224922de9469f78b — Jordan Robinson 2 months ago 33293eb
update allow for docs user if env variable
2 files changed, 7 insertions(+), 1 deletions(-)

M main/middleware.py
M mataroa/settings.py
M main/middleware.py => main/middleware.py +5 -1
@@ 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():

M mataroa/settings.py => mataroa/settings.py +2 -0
@@ 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",