commit d485d7a5ff870f99e936a2c2289b7fce426ef5bd
parent f14d4fee92c6e47600c96b7d42d18611c10226b5
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 8 Jun 2026 21:55:57 +0200
add DELETE ToS accepted needed to avoid looping
Diffstat:
2 files changed, 100 insertions(+), 0 deletions(-)
diff --git a/src/backenddb/delete_tos_accepted_early.c b/src/backenddb/delete_tos_accepted_early.c
@@ -0,0 +1,48 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file src/backenddb/delete_tos_accepted_early.c
+ * @brief Implementation of the delete_tos_accepted_early function for Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <taler/taler_pq_lib.h>
+#include "merchant-database/delete_tos_accepted_early.h"
+#include "helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_delete_tos_accepted_early (
+ struct TALER_MERCHANTDB_PostgresContext *pg,
+ const char *merchant_id,
+ const char *exchange_url)
+{
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (exchange_url),
+ GNUNET_PQ_query_param_end
+ };
+
+ GNUNET_assert (NULL != pg->current_merchant_id);
+ GNUNET_assert (0 == strcmp (merchant_id,
+ pg->current_merchant_id));
+ check_connection (pg);
+ TMH_PQ_prepare_anon (pg,
+ "DELETE FROM merchant_tos_accepted"
+ " WHERE exchange_url=$1");
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "",
+ params);
+}
diff --git a/src/include/merchant-database/delete_tos_accepted_early.h b/src/include/merchant-database/delete_tos_accepted_early.h
@@ -0,0 +1,52 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2026 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file src/include/merchant-database/delete_tos_accepted_early.h
+ * @brief implementation of the delete_tos_accepted_early function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef MERCHANT_DATABASE_DELETE_TOS_ACCEPTED_EARLY_H
+#define MERCHANT_DATABASE_DELETE_TOS_ACCEPTED_EARLY_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "merchantdb_lib.h"
+
+
+struct TALER_MERCHANTDB_PostgresContext;
+
+/**
+ * Clear any record that the user has accepted the terms of
+ * service of the exchange identified by @a exchange_url ahead
+ * of the regular KYC flow (via the ``POST /private/accept-tos-early``
+ * endpoint). This effectively sets the accepted
+ * ``Taler-Terms-Version`` back to NULL so that a subsequent
+ * #TALER_MERCHANTDB_lookup_tos_accepted_early returns
+ * ``GNUNET_DB_STATUS_SUCCESS_NO_RESULTS``.
+ *
+ * @param pg database context
+ * @param merchant_id merchant backend instance ID
+ * @param exchange_url base URL of the exchange to clear the
+ * early terms-of-service acceptance for
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_delete_tos_accepted_early (
+ struct TALER_MERCHANTDB_PostgresContext *pg,
+ const char *merchant_id,
+ const char *exchange_url);
+
+#endif