commit 78443e8231309007b559b2256dffc0696f31bcb0
parent b42c2443758d98954add139835ab2a8c8934b6af
Author: Sebastian <sebasjm@gmail.com>
Date: Mon, 24 Nov 2025 11:09:23 -0300
fix #10638
Diffstat:
1 file changed, 31 insertions(+), 23 deletions(-)
diff --git a/packages/merchant-backoffice-ui/src/components/SolveMFA.tsx b/packages/merchant-backoffice-ui/src/components/SolveMFA.tsx
@@ -6,7 +6,7 @@ import {
HttpStatusCode,
opEmptySuccess,
TalerErrorCode,
- TanChannel
+ TanChannel,
} from "@gnu-taler/taler-util";
import {
ButtonBetterBulma,
@@ -14,7 +14,7 @@ import {
SafeHandlerTemplate,
undefinedIfEmpty,
useLocalNotificationBetter,
- useTranslationContext
+ useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { format } from "date-fns";
import { Fragment, h, VNode } from "preact";
@@ -84,19 +84,25 @@ function SolveChallenge({
};
setValue(v);
}
- const data = !value.code || !!errors ? undefined : { tan: value.code }
+ const data = !value.code || !!errors ? undefined : { tan: value.code };
const [notification, safeFunctionHandler] = useLocalNotificationBetter();
- const verify = safeFunctionHandler(lib.instance.confirmChallenge.bind(lib.instance), !data ? undefined : [challenge.challenge_id, data])
- verify.onSuccess = onSolved
+ const verify = safeFunctionHandler(
+ lib.instance.confirmChallenge.bind(lib.instance),
+ !data ? undefined : [challenge.challenge_id, data],
+ );
+ verify.onSuccess = onSolved;
verify.onFail = (fail) => {
switch (fail.case) {
- case HttpStatusCode.Unauthorized: return i18n.str`Unauthorized`
- case TalerErrorCode.MERCHANT_TAN_CHALLENGE_FAILED: return i18n.str`Sending the code failed`
- case TalerErrorCode.MERCHANT_TAN_CHALLENGE_UNKNOWN: return i18n.str`Challenge expired`
- case TalerErrorCode.MERCHANT_TAN_TOO_MANY_ATTEMPTS: return i18n.str`Too many attempts`
+ case HttpStatusCode.Unauthorized:
+ return i18n.str`Unauthorized`;
+ case TalerErrorCode.MERCHANT_TAN_CHALLENGE_FAILED:
+ return i18n.str`Sending the code failed`;
+ case TalerErrorCode.MERCHANT_TAN_CHALLENGE_UNKNOWN:
+ return i18n.str`Challenge expired`;
+ case TalerErrorCode.MERCHANT_TAN_TOO_MANY_ATTEMPTS:
+ return i18n.str`Too many attempts`;
}
- }
-
+ };
return (
<Fragment>
@@ -178,10 +184,7 @@ function SolveChallenge({
<button class="button" type="button" onClick={onCancel}>
<i18n.Translate>Back</i18n.Translate>
</button>
- <ButtonBetterBulma
- type="submit"
- onClick={verify}
- >
+ <ButtonBetterBulma type="submit" onClick={verify}>
<i18n.Translate>Verify</i18n.Translate>
</ButtonBetterBulma>
</footer>
@@ -239,9 +242,16 @@ export function SolveMFAChallenges({
// }}
onSolved={() => {
setSelected(undefined);
- setSolved([...solved, selected.ch.challenge_id]);
+ const total = [...solved, selected.ch.challenge_id];
+ const enough = currentChallenge.combi_and
+ ? total.length === currentChallenge.challenges.length
+ : total.length > 0;
+ if (enough) {
+ onCompleted.withArgs(total).call();
+ } else {
+ setSolved(total);
+ }
}}
-
/>
);
}
@@ -360,7 +370,8 @@ export function SolveMFAChallenges({
case TanChannel.EMAIL:
return (
<i18n.Translate>
- An email to the address starting with {challenge.tan_info}
+ An email to the address starting with{" "}
+ {challenge.tan_info}
</i18n.Translate>
);
}
@@ -403,7 +414,7 @@ export function SolveMFAChallenges({
// alreadySent
// }
onClick={doSend}
- // onClick={() => doSendCodeImpl(d)}
+ // onClick={() => doSendCodeImpl(d)}
>
<i18n.Translate>Send me a message</i18n.Translate>
</ButtonBetterBulma>
@@ -422,10 +433,7 @@ export function SolveMFAChallenges({
<button class="button" onClick={onCancel}>
<i18n.Translate>Cancel</i18n.Translate>
</button>
- <ButtonBetterBulma
- type="is-info"
- onClick={doComplete}
- >
+ <ButtonBetterBulma type="is-info" onClick={doComplete}>
<i18n.Translate>Complete</i18n.Translate>
</ButtonBetterBulma>
</footer>