From d13b261bcb213e9ae051a8f07d3bedd634fe8f5a Mon Sep 17 00:00:00 2001 From: p7996619 <5589968+p7996619@users.noreply.github.com> Date: Tue, 8 Jul 2025 21:18:42 +0200 Subject: [PATCH 1/2] Make logout redirect URL configurable through environment variable --- src/config/settings.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/config/settings.py b/src/config/settings.py index 0690d0550..f1a634e69 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -4,7 +4,7 @@ import warnings import zoneinfo from pathlib import Path -from urllib.parse import urlparse +from urllib.parse import urljoin, urlparse from celery.schedules import crontab from decouple import ( @@ -503,7 +503,9 @@ def secret(key, default=undefined, **kwargs): # Empty CSRF_TRUSTED_ORIGINS, default to http ACCOUNT_DEFAULT_HTTP_PROTOCOL = "http" -ACCOUNT_LOGOUT_REDIRECT_URL = "/accounts/login/?loggedout=1" +ACCOUNT_LOGOUT_REDIRECT_URL = config( + "ACCOUNT_LOGOUT_REDIRECT_URL", default="/accounts/login/?loggedout=1" +) ACCOUNT_SESSION_REMEMBER = True ACCOUNT_USER_MODEL_EMAIL_FIELD = None ACCOUNT_FORMS = { @@ -512,7 +514,9 @@ def secret(key, default=undefined, **kwargs): } if BASE_URL: - ACCOUNT_LOGOUT_REDIRECT_URL = f"{BASE_URL}/accounts/login/?loggedout=1" + # Join base only if relative URL + if not urlparse(ACCOUNT_LOGOUT_REDIRECT_URL).netloc: + ACCOUNT_LOGOUT_REDIRECT_URL = urljoin(BASE_URL, ACCOUNT_LOGOUT_REDIRECT_URL) SESSION_COOKIE_PATH = BASE_URL + "/" SOCIALACCOUNT_LOGIN_ON_GET = True From 3960ac6a0e9cdcfc8406e4e8094b447be92eb154 Mon Sep 17 00:00:00 2001 From: p7996619 <5589968+p7996619@users.noreply.github.com> Date: Tue, 8 Jul 2025 21:47:33 +0200 Subject: [PATCH 2/2] Add missing trailing comma --- src/config/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/settings.py b/src/config/settings.py index f1a634e69..3ea4d0d2b 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -504,7 +504,7 @@ def secret(key, default=undefined, **kwargs): ACCOUNT_DEFAULT_HTTP_PROTOCOL = "http" ACCOUNT_LOGOUT_REDIRECT_URL = config( - "ACCOUNT_LOGOUT_REDIRECT_URL", default="/accounts/login/?loggedout=1" + "ACCOUNT_LOGOUT_REDIRECT_URL", default="/accounts/login/?loggedout=1", ) ACCOUNT_SESSION_REMEMBER = True ACCOUNT_USER_MODEL_EMAIL_FIELD = None