[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-bank] branch master updated: allow/deny registrations based on co
From: |
gnunet |
Subject: |
[taler-bank] branch master updated: allow/deny registrations based on config |
Date: |
Mon, 20 Jan 2020 13:43:07 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository bank.
The following commit(s) were added to refs/heads/master by this push:
new 46c04a7 allow/deny registrations based on config
46c04a7 is described below
commit 46c04a78099566e2f6de9d29270632d5adfc68c1
Author: Florian Dold <address@hidden>
AuthorDate: Mon Jan 20 13:43:04 2020 +0100
allow/deny registrations based on config
---
talerbank/app/templates/login.html | 4 ++++
talerbank/app/views.py | 8 +++++++-
talerbank/settings.py | 7 +++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/talerbank/app/templates/login.html
b/talerbank/app/templates/login.html
index 49cef61..364231d 100644
--- a/talerbank/app/templates/login.html
+++ b/talerbank/app/templates/login.html
@@ -49,11 +49,15 @@
<input type="hidden" name="next" value="{{ next }}" />
</form>
</div>
+ {% if settings_value("ALLOW_REGISTRATIONS") %}
<p>
If you are a new customer, please <a href="{{ url('register')
}}">register</a>.
Registration is fast and free, and it gives you a registration bonus
of 100 {{ settings_value("TALER_CURRENCY") }}!
</p>
+ {% else %}
+ <p>Registrations are not open to the public.</p>
+ {% endif %}
<p>
To view transactions of public accounts,
please <a href="{{ url('public-accounts') }}">click here</a>.
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 0a02907..9cd941d 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -391,6 +391,8 @@ class UserReg(forms.Form):
def internal_register(request):
+ if not settings.ALLOW_REGISTRATIONS:
+ raise Exception("registration not allowed!")
input_data = UserReg(request.POST)
if not input_data.is_valid():
@@ -428,7 +430,8 @@ def register_headless(request):
This method serves the request for programmatically
registering a user.
"""
-
+ if not settings.ALLOW_REGISTRATIONS:
+ return JsonResponse(dict(error="registrations are not allowed"),
status=403)
try:
user = internal_register(request)
except UsernameUnavailable:
@@ -446,6 +449,9 @@ def register(request):
otherwise it will show again the same form (currently, without
displaying _any_ error/warning message.)
"""
+ if not settings.ALLOW_REGISTRATIONS:
+ # FIXME: shouldn't be JSON!
+ return JsonResponse(dict(error="registrations are not allowed"),
status=403)
if request.method != "POST":
return render(request, "register.html")
diff --git a/talerbank/settings.py b/talerbank/settings.py
index 6b39226..8e4c104 100644
--- a/talerbank/settings.py
+++ b/talerbank/settings.py
@@ -208,3 +208,10 @@ TALER_PREDEFINED_ACCOUNTS = [
TALER_EXPECTS_DONATIONS = ["Tor", "GNUnet", "Taler", "FSF"]
TALER_SUGGESTED_EXCHANGE = TC.value_string("bank", "suggested_exchange")
TALER_SUGGESTED_EXCHANGE_PAYTO = TC.value_string("bank",
"suggested_exchange_payto")
+
+_allow_reg = TC.value_string("bank", "ALLOW_REGISTRATIONS", default="no")
+
+if _allow_reg.lower() == "yes":
+ ALLOW_REGISTRATIONS = True
+else:
+ ALLOW_REGISTRATIONS = False
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-bank] branch master updated: allow/deny registrations based on config,
gnunet <=