-proper conflict on /register for existing account with different pw

This commit is contained in:
Christian Grothoff 2022-08-25 19:43:16 +02:00
parent 485466f021
commit 8322527536
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 48 additions and 7 deletions

@ -1 +1 @@
Subproject commit 2e264e2856ee1f490d894a64d36bd4eac71802eb Subproject commit a8ec467f79aab32f671c146ca9cffb812920e1a2

View File

@ -239,6 +239,11 @@ struct Account
*/ */
char *payto_uri; char *payto_uri;
/**
* Password set for the account (if any).
*/
char *password;
/** /**
* Current account balance. * Current account balance.
*/ */
@ -1415,6 +1420,7 @@ free_account (void *cls,
GNUNET_free (account->account_name); GNUNET_free (account->account_name);
GNUNET_free (account->receiver_name); GNUNET_free (account->receiver_name);
GNUNET_free (account->payto_uri); GNUNET_free (account->payto_uri);
GNUNET_free (account->password);
GNUNET_free (account); GNUNET_free (account);
return GNUNET_OK; return GNUNET_OK;
} }
@ -2826,6 +2832,20 @@ do_post_withdrawal (struct TALER_FAKEBANK_Handle *h,
credit_account = lookup_account (h, credit_account = lookup_account (h,
credit_name, credit_name,
NULL); NULL);
if (NULL == credit_account)
{
MHD_RESULT res;
GNUNET_break_op (0);
GNUNET_assert (0 ==
pthread_mutex_unlock (&h->big_lock));
res = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_BANK_UNKNOWN_ACCOUNT,
credit_name);
GNUNET_free (credit_name);
return res;
}
GNUNET_free (credit_name); GNUNET_free (credit_name);
if ( (NULL != wo->exchange_account) && if ( (NULL != wo->exchange_account) &&
(credit_account != wo->exchange_account) ) (credit_account != wo->exchange_account) )
@ -3381,6 +3401,7 @@ post_testing_register (struct TALER_FAKEBANK_Handle *h,
GNUNET_JSON_spec_end () GNUNET_JSON_spec_end ()
}; };
enum GNUNET_GenericReturnValue ret; enum GNUNET_GenericReturnValue ret;
struct Account *acc;
if (GNUNET_OK != if (GNUNET_OK !=
(ret = TALER_MHD_parse_json_data (connection, (ret = TALER_MHD_parse_json_data (connection,
@ -3391,12 +3412,32 @@ post_testing_register (struct TALER_FAKEBANK_Handle *h,
json_decref (json); json_decref (json);
return (GNUNET_NO == ret) ? MHD_YES : MHD_NO; return (GNUNET_NO == ret) ? MHD_YES : MHD_NO;
} }
(void) lookup_account (h, acc = lookup_account (h,
username, username,
username); NULL);
return TALER_MHD_reply_json (connection, if (NULL != acc)
json_object (), /* FIXME: #7301 */ {
MHD_HTTP_OK); if (0 != strcmp (password,
acc->password))
{
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_CONFLICT,
TALER_EC_BANK_REGISTER_CONFLICT,
"password");
}
}
else
{
acc = lookup_account (h,
username,
username);
acc->password = GNUNET_strdup (password);
}
return TALER_MHD_reply_static (connection,
MHD_HTTP_NO_CONTENT,
NULL,
NULL,
0);
} }
json_decref (json); json_decref (json);
return res; return res;