commit 2672d10e87d502c5dc05acf778f4ffcc73bb0973
parent 53651c3f51f83ff12628757b9d8e4cd841fd79cb
Author: ms <ms@taler.net>
Date: Fri, 29 Apr 2022 16:38:55 +0200
error handling upon withdrawal
Diffstat:
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/packages/bank/src/pages/home/index.tsx b/packages/bank/src/pages/home/index.tsx
@@ -1011,6 +1011,12 @@ function TalerWithdrawalQRCode(Props: any): VNode {
accountLabel,
backendState } = Props;
const i18n = useTranslator();
+ const abortButton = <a class="pure-button" onClick={() => {
+ pageStateSetter((prevState: PageStateType) => {
+ const { withdrawalOutcome, withdrawalId, talerWithdrawUri, ...rest } = prevState;
+ return { ...rest, withdrawalInProgress: false };
+ })}}>{i18n`Abort`}</a>
+
console.log(`Showing withdraw URI: ${talerWithdrawUri}`);
// waiting for the wallet:
@@ -1018,8 +1024,12 @@ function TalerWithdrawalQRCode(Props: any): VNode {
if (typeof error !== "undefined") {
console.log(`withdrawal (${withdrawalId}) was never (correctly) created at the bank...`, error);
pageStateSetter((prevState: PageStateType) => ({
- ...prevState, hasError: true, error: error
- }))}
+ ...prevState,
+ hasError: true,
+ error: i18n`withdrawal (${withdrawalId}) was never (correctly) created at the bank...`
+ }))
+ return (<Fragment><br /><br />{abortButton}</Fragment>);
+ }
// data didn't arrive yet and wallet didn't communicate:
if (typeof data === "undefined") {
@@ -1053,11 +1063,7 @@ function TalerWithdrawalQRCode(Props: any): VNode {
{QR({text: talerWithdrawUri})}
<p>Click <a href={talerWithdrawUri}>{i18n`this link`}</a> to open your Taler wallet!</p>
<br />
- <a class="pure-button" onClick={() => {
- pageStateSetter((prevState: PageStateType) => {
- const { withdrawalOutcome, withdrawalId, talerWithdrawUri, ...rest } = prevState;
- return { ...rest, withdrawalInProgress: false };
- })}}>{i18n`Abort`}</a>
+ {abortButton}
</section>);
}
/**
@@ -1204,7 +1210,7 @@ function RegistrationForm(Props: any): VNode {
username: e.currentTarget.value,
}))}} />
<input
- type="text"
+ type="password"
placeholder="password"
required
autofocus
@@ -1345,16 +1351,20 @@ function Account(Props: any): VNode {
/**
* 404 should never stick to the cache, because they
- * taint successful registrations:
+ * taint successful future registrations. How? After
+ * registering, the user gets navigated to this page,
+ * therefore a previous 404 on this SWR key (the requested
+ * resource) would still appear as valid and cause this
+ * page not to be shown! A typical case is an attempted
+ * login of a unregistered user X, and then a registration
+ * attempt of the same user X: in this case, the failed
+ * login would cache a 404 error to X's profile, resulting
+ * in the legitimate request after the registration to still
+ * be flagged as 404. Clearing the cache should prevent
+ * this and likely not pose additional problems (given that
+ * the user couldn't have been logged before).
*/
- console.log("Cache at Account:", cache);
- for (const key of Object.keys(cache)) {
- console.log("processing key: " + key);
- if (RegExp(`${endpoint}$`).test(key)) {
- console.log("Deleting key: " + key);
- cache.delete(key)
- }
- }
+ (cache as any).clear();
return <p>Profile not found...</p>;
}
case 401: {