marc suggestions from email

This commit is contained in:
Sebastian 2022-12-30 14:23:58 -03:00
parent 26d94c4ba7
commit 90ec5b51ea
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
2 changed files with 13 additions and 8 deletions

View File

@ -23,7 +23,7 @@ import { BackendStateHandler } from "../hooks/backend.js";
import { bankUiSettings } from "../settings.js"; import { bankUiSettings } from "../settings.js";
import { getBankBackendBaseUrl, undefinedIfEmpty } from "../utils.js"; import { getBankBackendBaseUrl, undefinedIfEmpty } from "../utils.js";
import { ShowInputErrorLabel } from "./ShowInputErrorLabel.js"; import { ShowInputErrorLabel } from "./ShowInputErrorLabel.js";
import { USERNAME_REGEX } from "./RegistrationPage.js"; import { USERNAME_REGEX, PASSWORD_REGEX } from "./RegistrationPage.js";
/** /**
* Collect and submit login data. * Collect and submit login data.
@ -42,9 +42,13 @@ export function LoginForm(): VNode {
username: !username username: !username
? i18n.str`Missing username` ? i18n.str`Missing username`
: !USERNAME_REGEX.test(username) : !USERNAME_REGEX.test(username)
? i18n.str`Use only letter and numbers starting with a lower case letter` ? i18n.str`Use letters and numbers only, and start with a lowercase letter`
: undefined,
password: !password
? i18n.str`Missing password`
: !PASSWORD_REGEX.test(password)
? i18n.str`Use letters and numbers only, and start with a lowercase letter or number`
: undefined, : undefined,
password: !password ? i18n.str`Missing password` : undefined,
}); });
return ( return (

View File

@ -47,7 +47,8 @@ export function RegistrationPage(): VNode {
); );
} }
export const USERNAME_REGEX = /^[a-z][a-zA-Z0-9]+$/; export const USERNAME_REGEX = /^[a-z][a-zA-Z0-9]*$/;
export const PASSWORD_REGEX = /^[a-z0-9][a-zA-Z0-9]*$/;
/** /**
* Collect and submit registration data. * Collect and submit registration data.
@ -65,17 +66,17 @@ function RegistrationForm(): VNode {
username: !username username: !username
? i18n.str`Missing username` ? i18n.str`Missing username`
: !USERNAME_REGEX.test(username) : !USERNAME_REGEX.test(username)
? i18n.str`Use only letter and numbers starting with a lower case letter` ? i18n.str`Use letters and numbers only, and start with a lowercase letter`
: undefined, : undefined,
password: !password password: !password
? i18n.str`Missing password` ? i18n.str`Missing password`
: !USERNAME_REGEX.test(password) : !PASSWORD_REGEX.test(password)
? i18n.str`Use only letter and numbers starting with a lower case letter` ? i18n.str`Use letters and numbers only, and start with a lowercase letter`
: undefined, : undefined,
repeatPassword: !repeatPassword repeatPassword: !repeatPassword
? i18n.str`Missing password` ? i18n.str`Missing password`
: repeatPassword !== password : repeatPassword !== password
? i18n.str`Password don't match` ? i18n.str`Passwords don't match`
: undefined, : undefined,
}); });