diff options
author | Sebastian <sebasjm@gmail.com> | 2023-11-24 11:36:56 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-11-24 11:36:56 -0300 |
commit | 9ba6a59d18c9ab7d7690e556d7f9aedf0c370e52 (patch) | |
tree | f9b6a45cf2afd3b07c977a21241116758a1fe4c2 /packages/demobank-ui/src/pages/RegistrationPage.tsx | |
parent | 074d5986c5ba2d0fd181046f27ba0f2ffce5840f (diff) | |
download | wallet-core-9ba6a59d18c9ab7d7690e556d7f9aedf0c370e52.tar.xz |
using monitor api
Diffstat (limited to 'packages/demobank-ui/src/pages/RegistrationPage.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/RegistrationPage.tsx | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/packages/demobank-ui/src/pages/RegistrationPage.tsx b/packages/demobank-ui/src/pages/RegistrationPage.tsx index 9c3b21097..2de6de373 100644 --- a/packages/demobank-ui/src/pages/RegistrationPage.tsx +++ b/packages/demobank-ui/src/pages/RegistrationPage.tsx @@ -38,7 +38,7 @@ export function RegistrationPage({ onCancel: () => void; }): VNode { const { i18n } = useTranslationContext(); - const {config} = useBankCoreApiContext(); + const { config } = useBankCoreApiContext(); if (!config.allow_registrations) { return ( <p>{i18n.str`Currently, the bank is not accepting new registrations!`}</p> @@ -70,9 +70,9 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on const { i18n } = useTranslationContext(); const errors = undefinedIfEmpty({ - // name: !name - // ? i18n.str`Missing name` - // : undefined, + name: !name + ? i18n.str`Missing name` + : undefined, username: !username ? i18n.str`Missing username` : !USERNAME_REGEX.test(username) @@ -96,9 +96,9 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on : undefined, }); - async function doRegistrationAndLogin(name: string | undefined, username: string, password: string) { + async function doRegistrationAndLogin(name: string, username: string, password: string) { await handleError(async () => { - const creationResponse = await api.createAccount("" as AccessToken, { name: name ?? "", username, password }); + const creationResponse = await api.createAccount("" as AccessToken, { name, username, password }); if (creationResponse.type === "fail") { switch (creationResponse.case) { case "invalid-phone-or-email": return notify({ @@ -169,7 +169,7 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on } async function doRegistrationStep() { - if (!username || !password) return; + if (!username || !password || !name) return; await doRegistrationAndLogin(name, username, password) setUsername(undefined); setPassword(undefined); @@ -179,9 +179,10 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on async function doRandomRegistration(tries: number = 3) { const user = getRandomUsername(); - + const pass = settings.simplePasswordForRandomAccounts ? "123" : getRandomPassword(); const username = `_${user.first}-${user.second}_` + const name = `${user.first}, ${user.second}` await doRegistrationAndLogin(name, username, pass) onComplete(); } |