From 46624cbe5a27aefc97340955d9641a4505bc4880 Mon Sep 17 00:00:00 2001
From: flange <38500-flange@users.noreply.git.rwth-aachen.de>
Date: Wed, 26 Mar 2025 09:00:04 +0100
Subject: [PATCH] add a separate setting for the  socialaccount login error
 page

---
 .env_template       | 2 ++
 project/settings.py | 5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.env_template b/.env_template
index 94e3d4c..14663ce 100644
--- a/.env_template
+++ b/.env_template
@@ -6,3 +6,5 @@ IAM4NFDI_CLIENT_ID=
 IAM4NFDI_CLIENT_SECRET=
 # Redirect URI should point to the frontend's /auth/callback/iam4nfdi page (absolute URL).
 IAM4NFDI_REDIRECT_URI=
+# Frontend page to redirect to when OIDC login flow fails (absolute URL).
+IAM4NFDI_LOGIN_ERROR_PAGE=
diff --git a/project/settings.py b/project/settings.py
index 45cb444..1a485e0 100644
--- a/project/settings.py
+++ b/project/settings.py
@@ -147,10 +147,11 @@ SOCIALACCOUNT_PROVIDERS = {}
 IAM4NFDI_CLIENT_ID = os.environ.get("IAM4NFDI_CLIENT_ID", None)
 IAM4NFDI_CLIENT_SECRET = os.environ.get("IAM4NFDI_CLIENT_SECRET", None)
 IAM4NFDI_REDIRECT_URI = os.environ.get("IAM4NFDI_REDIRECT_URI", None)
+IAM4NFDI_LOGIN_ERROR_PAGE = os.environ.get("IAM4NFDI_LOGIN_ERROR_PAGE", None)
 
-if IAM4NFDI_CLIENT_ID and IAM4NFDI_CLIENT_SECRET and IAM4NFDI_REDIRECT_URI:
+if IAM4NFDI_CLIENT_ID and IAM4NFDI_CLIENT_SECRET and IAM4NFDI_REDIRECT_URI and IAM4NFDI_LOGIN_ERROR_PAGE:
     HEADLESS_FRONTEND_URLS = {
-        "socialaccount_login_error": IAM4NFDI_REDIRECT_URI,
+        "socialaccount_login_error": IAM4NFDI_LOGIN_ERROR_PAGE,
     }
 
     SOCIALACCOUNT_PROVIDERS["openid_connect"] = {
-- 
GitLab