diff options
Diffstat (limited to 'packages/demobank-ui/src/pages/account')
3 files changed, 27 insertions, 18 deletions
diff --git a/packages/demobank-ui/src/pages/account/CashoutListForAccount.tsx b/packages/demobank-ui/src/pages/account/CashoutListForAccount.tsx index f2972ed65..1676d8b6a 100644 --- a/packages/demobank-ui/src/pages/account/CashoutListForAccount.tsx +++ b/packages/demobank-ui/src/pages/account/CashoutListForAccount.tsx @@ -9,10 +9,11 @@ import { CreateCashout } from "../business/CreateCashout.js"; interface Props { account: string, onClose: () => void, + onAuthorizationRequired: () => void, onSelected: (cid: number) => void } -export function CashoutListForAccount({ account, onSelected, onClose }: Props): VNode { +export function CashoutListForAccount({ account, onAuthorizationRequired, onSelected, onClose }: Props): VNode { const { i18n } = useTranslationContext(); const { state: credentials } = useBackendState(); @@ -29,7 +30,7 @@ export function CashoutListForAccount({ account, onSelected, onClose }: Props): </h1> } - <CreateCashout focus onCancel={onClose} onComplete={() => { }} account={account} /> + <CreateCashout focus onCancel={onClose} onAuthorizationRequired={onAuthorizationRequired} account={account} /> <Cashouts account={account} diff --git a/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx b/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx index 28875bde6..ca3e2fbdf 100644 --- a/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx +++ b/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx @@ -1,4 +1,4 @@ -import { HttpStatusCode, TalerCorebankApi, TalerError, TalerErrorCode, TranslatedString } from "@gnu-taler/taler-util"; +import { AbsoluteTime, HttpStatusCode, TalerCorebankApi, TalerError, TalerErrorCode, TranslatedString } from "@gnu-taler/taler-util"; import { Loading, LocalNotificationBanner, notifyInfo, useLocalNotification, useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; @@ -16,9 +16,11 @@ export function ShowAccountDetails({ account, onClear, onUpdateSuccess, + onAuthorizationRequired, }: { onClear?: () => void; onUpdateSuccess: () => void; + onAuthorizationRequired: () => void, account: string; }): VNode { const { i18n } = useTranslationContext(); @@ -54,7 +56,6 @@ export function ShowAccountDetails({ const resp = await api.updateAccount({ token: creds.token, username: account, - }, submitAccount); if (resp.type === "ok") { @@ -99,11 +100,13 @@ export function ShowAccountDetails({ debug: resp.detail, }) case HttpStatusCode.Accepted: { - updateBankState("currentChallengeId", resp.body.challenge_id) - return notify({ - type: "info", - title: i18n.str`Cashout created but confirmation is required.`, - }); + updateBankState("currentChallenge", { + operation: "update-account", + id: String(resp.body.challenge_id), + sent: AbsoluteTime.never(), + request: submitAccount, + }) + return onAuthorizationRequired() } case TalerErrorCode.BANK_TAN_CHANNEL_NOT_SUPPORTED: { return notify({ @@ -122,7 +125,7 @@ export function ShowAccountDetails({ return ( <Fragment> - <LocalNotificationBanner notification={notification} /> + <LocalNotificationBanner notification={notification} showDebug={true} /> {accountIsTheCurrentUser ? <ProfileNavigation current="details" /> : diff --git a/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx b/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx index 0ff1cf725..3c4a865ed 100644 --- a/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx +++ b/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx @@ -9,17 +9,19 @@ import { doAutoFocus } from "../PaytoWireTransferForm.js"; import { ProfileNavigation } from "../ProfileNavigation.js"; import { assertUnreachable } from "../WithdrawalOperationPage.js"; import { LocalNotificationBanner } from "@gnu-taler/web-util/browser"; -import { HttpStatusCode, TalerErrorCode } from "@gnu-taler/taler-util"; +import { AbsoluteTime, HttpStatusCode, TalerErrorCode } from "@gnu-taler/taler-util"; import { useBankState } from "../../hooks/bank-state.js"; export function UpdateAccountPassword({ account: accountName, onCancel, onUpdateSuccess, + onAuthorizationRequired, focus, }: { onCancel: () => void; focus?: boolean, + onAuthorizationRequired: () => void, onUpdateSuccess: () => void; account: string; }): VNode { @@ -51,10 +53,11 @@ export function UpdateAccountPassword({ async function doChangePassword() { if (!!errors || !password || !token) return; await handleError(async () => { - const resp = await api.updatePassword({ username: accountName, token }, { + const request = { old_password: current, new_password: password, - }); + } + const resp = await api.updatePassword({ username: accountName, token }, request); if (resp.type === "ok") { notifyInfo(i18n.str`Password changed`); onUpdateSuccess(); @@ -77,11 +80,13 @@ export function UpdateAccountPassword({ title: i18n.str`Your current password doesn't match, can't change to a new password.` }) case HttpStatusCode.Accepted: { - updateBankState("currentChallengeId", resp.body.challenge_id) - return notify({ - type: "info", - title: i18n.str`Cashout created but confirmation is required.`, - }); + updateBankState("currentChallenge", { + operation: "update-password", + id: String(resp.body.challenge_id), + sent: AbsoluteTime.never(), + request, + }) + return onAuthorizationRequired() } default: assertUnreachable(resp) } |