[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 02/05: fix method deletion
From: |
gnunet |
Subject: |
[taler-anastasis] 02/05: fix method deletion |
Date: |
Mon, 12 Oct 2020 20:36:19 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit da8b7f63ccd2542954728dfdd2af75b56c449e50
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Mon Oct 12 16:15:39 2020 +0200
fix method deletion
---
src/lib/anastasis_api_backup_redux.c | 38 ++++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/src/lib/anastasis_api_backup_redux.c
b/src/lib/anastasis_api_backup_redux.c
index 81b5e81..e6faccc 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -155,15 +155,15 @@ add_authentication (json_t *state,
{
json_t *method = json_object_get (arguments, "authentication_method");
GNUNET_assert (NULL != method);
- json_t *auth_method_arr = json_object_get (state, "authentication_methods");
+ json_t *auth_method_arr = json_deep_copy (json_object_get (state,
+
"authentication_methods"));
if (NULL == auth_method_arr)
auth_method_arr = json_array ();
GNUNET_assert (NULL != auth_method_arr);
GNUNET_assert (0 == json_array_append_new (auth_method_arr, method));
- GNUNET_assert (0 == json_object_set (state,
- "authentication_methods",
- auth_method_arr));
-
+ GNUNET_assert (0 == json_object_set_new (state,
+ "authentication_methods",
+ auth_method_arr));
cb (cb_cls,
ANASTASIS_EC_NONE,
state);
@@ -392,18 +392,32 @@ del_authentication (json_t *state,
json_t *method_arr = json_deep_copy (json_object_get (state,
"authentication_methods"));
GNUNET_assert (NULL != method_arr);
+ json_t *del_method = json_object_get (arguments, "authentication_method");
+ GNUNET_assert (NULL != del_method);
json_array_foreach (method_arr, arr_index, method)
{
- const char *key;
- json_t *value;
- json_object_foreach (method, key, value)
+ json_t *method_type = json_object_get (method, "method");
+ if (1 == json_equal (method_type, json_object_get (del_method, "method")))
{
- if (0 == strcmp (json_string_value (value), json_string_value (
- arguments)))
+ const char *key;
+ json_t *value;
+ json_t *method_data = json_object_get (method, "data");
+ GNUNET_assert (NULL != method_data);
+ json_t *del_method_value = json_object_get (del_method, "value");
+ GNUNET_assert (NULL != del_method_value);
+
+ json_object_foreach (method_data, key, value)
{
- GNUNET_assert (0 == json_array_remove (method_arr, arr_index));
- break;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "VALUE: %s, DEL_VALUE: %s\n\n",
+ json_string_value (value),
+ json_string_value (del_method_value));
+ if (1 == json_equal (del_method_value, value))
+ {
+ GNUNET_assert (0 == json_array_remove (method_arr, arr_index));
+ break;
+ }
}
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.