gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: make create_token optional


From: gnunet
Subject: [taler-merchant] branch master updated: make create_token optional
Date: Mon, 27 Jul 2020 12:30:33 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 2eaa81f  make create_token optional
2eaa81f is described below

commit 2eaa81fe039f69f31eae74309f229e11c2b006e9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jul 27 12:30:31 2020 +0200

    make create_token optional
---
 .../taler-merchant-httpd_private-post-orders.c     | 50 ++++++++++++++++------
 1 file changed, 36 insertions(+), 14 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 441de30..86cf0b4 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1035,12 +1035,9 @@ TMH_private_post_orders (const struct TMH_RequestHandler 
*rh,
   unsigned int uuids_len = 0;
   struct GNUNET_Uuid *uuids = NULL;
   struct TALER_ClaimTokenP claim_token;
-  bool create_token;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_json ("order",
                            &order),
-    GNUNET_JSON_spec_bool ("create_token",
-                           &create_token),
     GNUNET_JSON_spec_end ()
   };
   enum GNUNET_GenericReturnValue ret;
@@ -1053,18 +1050,43 @@ TMH_private_post_orders (const struct 
TMH_RequestHandler *rh,
     return (GNUNET_NO == ret)
            ? MHD_YES
            : MHD_NO;
-  if (create_token)
-  {
-    GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
-                                &claim_token,
-                                sizeof (claim_token));
-  }
-  else
+
+  /* parse and handle the create_token (optionally given) */
   {
-    /* we use all-zeros for 'no token' */
-    memset (&claim_token,
-            0,
-            sizeof (claim_token));
+    bool create_token = true; /* default */
+
+    if (NULL != json_object_get (hc->request_body,
+                                 "create_token"))
+    {
+      struct GNUNET_JSON_Specification spec[] = {
+        GNUNET_JSON_spec_bool ("create_token",
+                               &create_token),
+        GNUNET_JSON_spec_end ()
+      };
+      enum GNUNET_GenericReturnValue ret;
+
+      (void) rh;
+      ret = TALER_MHD_parse_json_data (connection,
+                                       hc->request_body,
+                                       spec);
+      if (GNUNET_OK != ret)
+        return (GNUNET_NO == ret)
+               ? MHD_YES
+               : MHD_NO;
+    }
+    if (create_token)
+    {
+      GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+                                  &claim_token,
+                                  sizeof (claim_token));
+    }
+    else
+    {
+      /* we use all-zeros for 'no token' */
+      memset (&claim_token,
+              0,
+              sizeof (claim_token));
+    }
   }
   /* parse the refund_delay (optionally given) */
   if (NULL != json_object_get (hc->request_body,

-- 
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]