commit 7f3c819d910518e69dd71ee78a5d79fcfb51f13b
parent 548b1d1deb54080ceba911b1b6d6b6ea12fd6276
Author: Sebastian <sebasjm@gmail.com>
Date: Thu, 14 Nov 2024 19:36:14 -0300
add allowSimplePassword preference
Diffstat:
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/packages/bank-ui/src/hooks/preferences.ts b/packages/bank-ui/src/hooks/preferences.ts
@@ -33,6 +33,7 @@ interface Preferences {
showDemoDescription: boolean;
showInstallWallet: boolean;
showDebugInfo: boolean;
+ allowsSimplePassword: boolean;
fastWithdrawalForm: boolean;
showCopyAccount: boolean;
}
@@ -43,6 +44,7 @@ export const codecForPreferences = (): Codec<Preferences> =>
.property("showDemoDescription", codecForBoolean())
.property("showInstallWallet", codecForBoolean())
.property("showDebugInfo", codecForBoolean())
+ .property("allowsSimplePassword", codecForBoolean())
.property("fastWithdrawalForm", codecForBoolean())
.property("showCopyAccount", codecForBoolean())
.build("Preferences");
@@ -50,6 +52,7 @@ export const codecForPreferences = (): Codec<Preferences> =>
const defaultPreferences: Preferences = {
showWithdrawalSuccess: true,
showDemoDescription: true,
+ allowsSimplePassword: false,
showInstallWallet: true,
showDebugInfo: false,
fastWithdrawalForm: false,
@@ -107,6 +110,8 @@ export function getLabelForPreferences(
return i18n.str`Show demo description`;
case "showInstallWallet":
return i18n.str`Show install wallet first`;
+ case "allowsSimplePassword":
+ return i18n.str`Remove password length validation on registration`;
case "showDebugInfo":
return i18n.str`Show debug info`;
}
diff --git a/packages/bank-ui/src/pages/RegistrationPage.tsx b/packages/bank-ui/src/pages/RegistrationPage.tsx
@@ -27,6 +27,7 @@ import { useState } from "preact/hooks";
import { useSettingsContext } from "../context/settings.js";
import { undefinedIfEmpty } from "../utils.js";
import { getRandomPassword, getRandomUsername } from "./rnd.js";
+import { usePreferences } from "../hooks/preferences.js";
const TALER_SCREEN_ID = 110;
@@ -77,6 +78,7 @@ function RegistrationForm({
const [repeatPassword, setRepeatPassword] = useState<string | undefined>();
const [notification, , handleError] = useLocalNotification();
const settings = useSettingsContext();
+ const [pref] = usePreferences();
const {
lib: { bank: api },
@@ -103,7 +105,7 @@ function RegistrationForm({
// : undefined,
password: !password
? i18n.str`Missing password`
- : password.length < 8
+ : pref.allowsSimplePassword && password.length < 8
? i18n.str`The password should be longer than 8 letters`
: undefined,
repeatPassword: !repeatPassword
@@ -176,7 +178,9 @@ function RegistrationForm({
const user = getRandomUsername();
const password = settings.simplePasswordForRandomAccounts
- ? "123"
+ ? pref.allowsSimplePassword
+ ? "123"
+ : "12345678"
: getRandomPassword();
const username = `_${user.first}-${user.second}_`;
const name = `${capitalizeFirstLetter(user.first)} ${capitalizeFirstLetter(
@@ -267,14 +271,16 @@ function RegistrationForm({
isDirty={password !== undefined}
/>
</div>
- <p class="mt-2 text-sm text-gray-500">
- <i18n.Translate>
- Use a strong password: 8 characters minimum, don't use any
- public information related to you (names, birthday, phone
- number, etc...) and mix lowercase, uppercase, symbols and
- numbers
- </i18n.Translate>
- </p>
+ {pref.allowsSimplePassword ? undefined : (
+ <p class="mt-2 text-sm text-gray-500">
+ <i18n.Translate>
+ Use a strong password: 8 characters minimum, don't use any
+ public information related to you (names, birthday, phone
+ number, etc...) and mix lowercase, uppercase, symbols and
+ numbers
+ </i18n.Translate>
+ </p>
+ )}
</div>
<div>
diff --git a/packages/bank-ui/src/settings.ts b/packages/bank-ui/src/settings.ts
@@ -33,7 +33,7 @@ export interface UiSettings {
// Useful for testing
// default: false
allowRandomAccountCreation?: boolean;
- // Create all random accounts with password "123"
+ // Create all random accounts with password "12345678" or "123"
// Useful for testing
// default: false
simplePasswordForRandomAccounts?: boolean;