[Fix] Add Captcha vars to Template (#359)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#359
This commit is contained in:
2026-03-13 11:46:34 +13:00
parent 21f3390a43
commit 3cc7fa9e8b
3 changed files with 25 additions and 11 deletions

View File

@ -147,6 +147,9 @@ def handler500(request):
def login(request): def login(request):
context = get_base_context(request) context = get_base_context(request)
if s.CAP_ENABLED:
context["CAP_ENABLED"] = s.CAP_ENABLED
context["CAP_API_BASE"] = s.CAP_API_BASE context["CAP_API_BASE"] = s.CAP_API_BASE
context["CAP_SITE_KEY"] = s.CAP_SITE_KEY context["CAP_SITE_KEY"] = s.CAP_SITE_KEY
@ -227,6 +230,11 @@ def logout(request):
def register(request): def register(request):
context = get_base_context(request) context = get_base_context(request)
if s.CAP_ENABLED:
context["CAP_ENABLED"] = s.CAP_ENABLED
context["CAP_API_BASE"] = s.CAP_API_BASE
context["CAP_SITE_KEY"] = s.CAP_SITE_KEY
if request.method == "GET": if request.method == "GET":
# Redirect to unified login page with signup tab # Redirect to unified login page with signup tab
next_url = request.GET.get("next", "") next_url = request.GET.get("next", "")

View File

@ -218,9 +218,11 @@
<input type="hidden" name="next" value="{{ next }}" /> <input type="hidden" name="next" value="{{ next }}" />
{% if CAP_ENABLED %}
<cap-widget <cap-widget
data-cap-api-endpoint="{{ CAP_API_BASE }}/{{ CAP_SITE_KEY }}/" data-cap-api-endpoint="{{ CAP_API_BASE }}/{{ CAP_SITE_KEY }}/"
></cap-widget> ></cap-widget>
{% endif %}
<!-- ToS and Academic Use Notice --> <!-- ToS and Academic Use Notice -->
<div class="text-xs text-base-content/70 mt-2"> <div class="text-xs text-base-content/70 mt-2">

View File

@ -19,12 +19,16 @@
type="text/css" type="text/css"
/> />
{% if CAP_ENABLED %}
<script src="https://cdn.jsdelivr.net/npm/@cap.js/widget@0.1.41/cap.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@cap.js/widget@0.1.41/cap.min.js"></script>
<link <link
rel="stylesheet" rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@cap.js/widget@0.1.41/src/cap.min.css" href="https://cdn.jsdelivr.net/npm/@cap.js/widget@0.1.41/src/cap.min.css"
/> />
{% block extra_styles %}{% endblock %} {% endif %}
{% block extra_styles %}
{% endblock %}
</head> </head>
<body class="bg-base-100"> <body class="bg-base-100">
<div class="flex h-screen"> <div class="flex h-screen">