commit 528804bebbe5aba8376fbb7b5c46338a1883db3a
parent 126dd00f2af997142497966a173e74f384ed62db
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Mon, 4 Aug 2025 17:13:02 +0200
store/restore phone number in merchant backend database
Diffstat:
5 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/src/backenddb/merchant-0022.sql b/src/backenddb/merchant-0022.sql
@@ -27,7 +27,8 @@ SELECT _v.register_patch('merchant-0022', NULL, NULL);
SET search_path TO merchant;
ALTER TABLE merchant_instances
- ADD COLUMN phone_number TEXT DEFAULT NULL;
+ ADD COLUMN phone_number TEXT DEFAULT NULL,
+ DROP COLUMN user_type;
COMMENT ON COLUMN merchant_instances.phone_number
IS 'Phone number of the merchant to use for password reset (and to contact the merchant as the backend operator); optional if 2-FA is not used and/or for legacy instances';
diff --git a/src/backenddb/pg_insert_instance.c b/src/backenddb/pg_insert_instance.c
@@ -56,6 +56,9 @@ TMH_PG_insert_instance (
(NULL == is->logo)
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_string (is->logo),
+ (NULL == is->phone)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (is->phone),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_QueryParam params_priv[] = {
@@ -82,9 +85,9 @@ TMH_PG_insert_instance (
",website"
",email"
",logo"
- ",user_type)"
+ ",phone_number)"
"VALUES"
- "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, 0)");
+ "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)");
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_instance",
params);
diff --git a/src/backenddb/pg_lookup_instances.c b/src/backenddb/pg_lookup_instances.c
@@ -119,6 +119,10 @@ lookup_instances_cb (void *cls,
&is.email),
NULL),
GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("phone_number",
+ &is.phone),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_string ("logo",
&is.logo),
NULL),
@@ -184,6 +188,7 @@ TMH_PG_lookup_instances (void *cls,
",mi.default_pay_delay"
",mi.website"
",mi.email"
+ ",mi.phone_number"
",mi.logo"
",mk.merchant_priv"
" FROM merchant_instances mi"
@@ -205,6 +210,7 @@ TMH_PG_lookup_instances (void *cls,
",mi.default_pay_delay"
",mi.website"
",mi.email"
+ ",mi.phone_number"
",mi.logo"
",mk.merchant_priv"
" FROM merchant_instances mi"
@@ -260,6 +266,7 @@ TMH_PG_lookup_instance (void *cls,
",mi.default_pay_delay"
",mi.website"
",mi.email"
+ ",mi.phone_number"
",mi.logo"
",mk.merchant_priv"
" FROM merchant_instances mi"
@@ -275,7 +282,6 @@ TMH_PG_lookup_instance (void *cls,
",mi.auth_salt"
",mi.merchant_id"
",mi.merchant_name"
- ",mi.user_type"
",mi.address"
",mi.jurisdiction"
",mi.use_stefan"
@@ -283,6 +289,7 @@ TMH_PG_lookup_instance (void *cls,
",mi.default_pay_delay"
",mi.website"
",mi.email"
+ ",mi.phone_number"
",mi.logo"
",mk.merchant_priv"
" FROM merchant_instances mi"
diff --git a/src/backenddb/pg_update_instance.c b/src/backenddb/pg_update_instance.c
@@ -51,6 +51,9 @@ TMH_PG_update_instance (void *cls,
(NULL == is->logo)
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_string (is->logo),
+ (NULL == is->phone)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (is->phone),
GNUNET_PQ_query_param_end
};
@@ -67,6 +70,7 @@ TMH_PG_update_instance (void *cls,
",website=$8"
",email=$9"
",logo=$10"
+ ",phone_number=$11"
" WHERE merchant_id=$1");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"update_instance",
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
@@ -180,11 +180,16 @@ struct TALER_MERCHANTDB_InstanceSettings
char *website;
/**
- * email contact for customers
+ * email contact for password reset / possibly admin / customers
*/
char *email;
/**
+ * phone contact for password reset / possibly admin / customers
+ */
+ char *phone;
+
+ /**
* merchant's logo data uri
*/
char *logo;