gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-bank] branch master updated: taler://withdraw URIs


From: gnunet
Subject: [taler-bank] branch master updated: taler://withdraw URIs
Date: Tue, 28 Jul 2020 19:53:02 +0200

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 bfb1d38  taler://withdraw URIs
bfb1d38 is described below

commit bfb1d387c5f0870584aee6e188da2f0b2c4e700e
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Tue Jul 28 23:22:46 2020 +0530

    taler://withdraw URIs
---
 talerbank/app/views.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index c2d512a..afe4487 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -39,7 +39,7 @@ from django.contrib.auth.decorators import login_required
 from django.views.decorators.csrf import csrf_exempt
 from django.views.decorators.http import require_POST, require_GET
 from django.views.decorators.http import require_http_methods
-from django.urls import reverse
+from django.urls import reverse, get_script_prefix
 from django.contrib.auth.models import User
 from django.db.models import Q
 from django.http import JsonResponse, HttpResponse
@@ -962,6 +962,19 @@ def basic_auth(request):
     username, password = base64.b64decode(tokens[1]).decode("utf-8").split(":")
     return django.contrib.auth.authenticate(username=username, 
password=password)
 
+def make_taler_withdraw_uri(request, withdraw_id):
+    if request.is_secure():
+        proto_extra = ""
+    else:
+        proto_extra = "+http"
+    pfx = get_script_prefix().strip("/")
+    if len(pfx) == 0:
+        pfx_components = []
+    else:
+        pfx_components = pfx.split("/")
+    host = request.get_host()
+    p = "/".join([host] + pfx_components + [str(withdraw_id)])
+    return f"taler{proto_extra}://withdraw/{p}"
 
 @login_via_headers
 @csrf_exempt
@@ -979,8 +992,7 @@ def withdraw_headless_uri(request, user):
         )
     op = TalerWithdrawOperation(amount=amount, withdraw_account=user_account)
     op.save()
-    host = request.get_host()
-    taler_withdraw_uri = f"taler://withdraw/{host}/{op.withdraw_id}"
+    taler_withdraw_uri = make_taler_withdraw_uri(request, op.withdraw_id)
     return JsonResponse({"taler_withdraw_uri": taler_withdraw_uri,})
 
 
@@ -1122,8 +1134,7 @@ def show_withdrawal(request, withdraw_id):
     op = TalerWithdrawOperation.objects.get(withdraw_id=withdraw_id)
     if op.selection_done:
         return redirect("withdraw-confirm", withdraw_id=op.withdraw_id)
-    host = request.get_host()
-    taler_withdraw_uri = f"taler://withdraw/{host}/-/{op.withdraw_id}"
+    taler_withdraw_uri = make_taler_withdraw_uri(request, op.withdraw_id)
     qrcode_svg = get_qrcode_svg(taler_withdraw_uri)
     context = dict(
         taler_withdraw_uri=taler_withdraw_uri,
@@ -1298,8 +1309,7 @@ def bank_accounts_api_create_withdrawal(request, user, 
acct_id):
         )
     op = TalerWithdrawOperation(amount=amount, withdraw_account=user_account)
     op.save()
-    host = request.get_host()
-    taler_withdraw_uri = f"taler://withdraw/{host}/{op.withdraw_id}"
+    taler_withdraw_uri = make_taler_withdraw_uri(request, op.withdraw_id)
     return JsonResponse(
         {"taler_withdraw_uri": taler_withdraw_uri, "withdrawal_id": 
op.withdraw_id}
     )

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]