diff options
author | Sebastian <sebasjm@gmail.com> | 2023-11-06 11:54:45 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-11-06 11:54:45 -0300 |
commit | 4ee903eb5e639fa0e122a689cc431e8f18ca1197 (patch) | |
tree | d2cf28bcddb03f650fe7913ff2db8e48145740c4 /packages/aml-backoffice-ui/src/pages/CreateAccount.tsx | |
parent | 3d1ab082d4a66df08fcb468d04198c055d00b8c5 (diff) | |
download | wallet-core-4ee903eb5e639fa0e122a689cc431e8f18ca1197.tar.xz |
aml ui
Diffstat (limited to 'packages/aml-backoffice-ui/src/pages/CreateAccount.tsx')
-rw-r--r-- | packages/aml-backoffice-ui/src/pages/CreateAccount.tsx | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/packages/aml-backoffice-ui/src/pages/CreateAccount.tsx b/packages/aml-backoffice-ui/src/pages/CreateAccount.tsx index 5dcb8b21d..9b8c3c046 100644 --- a/packages/aml-backoffice-ui/src/pages/CreateAccount.tsx +++ b/packages/aml-backoffice-ui/src/pages/CreateAccount.tsx @@ -5,6 +5,7 @@ import { } from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { createNewForm } from "../handlers/forms.js"; +import { useSettings } from "../hooks/useSettings.js"; export function CreateAccount({ onNewAccount, @@ -16,12 +17,13 @@ export function CreateAccount({ password: string; repeat: string; }>(); + const [settings] = useSettings() return ( <div class="flex min-h-full flex-col "> <div class="sm:mx-auto sm:w-full sm:max-w-md"> <h2 class="mt-6 text-center text-2xl font-bold leading-9 tracking-tight text-gray-900"> - Create account + <i18n.Translate>Create account</i18n.Translate> </h2> </div> @@ -33,29 +35,29 @@ export function CreateAccount({ password: { error: !v.password ? i18n.str`required` - : v.password.length < 8 - ? i18n.str`should have at least 8 characters` - : !v.password.match(/[a-z]/) && v.password.match(/[A-Z]/) - ? i18n.str`should have lowercase and uppercase characters` - : !v.password.match(/\d/) - ? i18n.str`should have numbers` - : !v.password.match(/[^a-zA-Z\d]/) - ? i18n.str`should have at least one character which is not a number or letter` - : undefined, + : settings.allowInsecurePassword + ? undefined + : v.password.length < 8 + ? i18n.str`should have at least 8 characters` + : !v.password.match(/[a-z]/) && v.password.match(/[A-Z]/) + ? i18n.str`should have lowercase and uppercase characters` + : !v.password.match(/\d/) + ? i18n.str`should have numbers` + : !v.password.match(/[^a-zA-Z\d]/) + ? i18n.str`should have at least one character which is not a number or letter` + : undefined, }, repeat: { error: !v.repeat ? i18n.str`required` : v.repeat !== v.password - ? i18n.str`doesn't match` - : undefined, + ? i18n.str`doesn't match` + : undefined, }, }; }} onSubmit={async (v, s) => { - console.log(v, s); const error = s?.password?.error ?? s?.repeat?.error; - console.log(error); if (error) { notifyError( "Can't create account" as TranslatedString, @@ -72,7 +74,9 @@ export function CreateAccount({ name="password" type="password" help={ - "lower and upper case letters, number and special character" as TranslatedString + settings.allowInsecurePassword + ? i18n.str`short password are insecure, turn off insecure password in settings` + : i18n.str`lower and upper case letters, number and special character` } required /> @@ -91,7 +95,7 @@ export function CreateAccount({ type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" > - Create + <i18n.Translate>Create</i18n.Translate> </button> </div> </Form.Provider> |