aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx')
-rw-r--r--packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx21
1 files changed, 13 insertions, 8 deletions
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)
}