summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/api/users.py10
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/auth-page.js6
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/de.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/en.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/es.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/it.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js1
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js1
12 files changed, 24 insertions, 2 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/api/users.py b/packages/meshbay-hub/src/meshbay_hub/api/users.py
index 05f58cd..9150909 100644
--- a/packages/meshbay-hub/src/meshbay_hub/api/users.py
+++ b/packages/meshbay-hub/src/meshbay_hub/api/users.py
@@ -78,6 +78,10 @@ async def _verify_captcha_or_raise(token: str | None, request: Request) -> None:
# ── Models ────────────────────────────────────────────────────────────────────
+# Mirrored by USERNAME_MIN_LEN in static/auth-page.js; test_username_floor.py
+# holds the two equal.
+USERNAME_MIN_LEN = 8
+
class RegisterRequest(BaseModel):
username: str
email: str
@@ -92,9 +96,11 @@ class RegisterRequest(BaseModel):
@field_validator("username")
@classmethod
def username_valid(cls, v: str) -> str:
+ # Registration only. Login, reset and deletion take the name as stored,
+ # so accounts created under the older 3-character floor keep working.
v = v.strip()
- if len(v) < 3 or len(v) > 64:
- raise ValueError("username must be 3-64 chars")
+ if len(v) < USERNAME_MIN_LEN or len(v) > 64:
+ raise ValueError(f"username must be {USERNAME_MIN_LEN}-64 chars")
if not v.replace("_", "").replace("-", "").replace(".", "").isalnum():
raise ValueError("username: only letters, digits, -, _, .")
return v
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/auth-page.js b/packages/meshbay-hub/src/meshbay_hub/static/auth-page.js
index d4dc5a4..04a00af 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/auth-page.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/auth-page.js
@@ -10,6 +10,9 @@ import { Icon } from './icon.js';
const PASSWORD_MIN_BITS = 60;
const PASSWORD_MIN_LEN = 12;
+// The hub's USERNAME_MIN_LEN (api/users.py), checked here so the refusal comes
+// before a passphrase derivation rather than after it.
+const USERNAME_MIN_LEN = 8;
// ── reCAPTCHA v2 helper ──────────────────────────────────────────────────────
@@ -284,6 +287,9 @@ export function RegisterPage() {
const onSubmit = async (e) => {
e.preventDefault();
const name = username.trim();
+ if (name.length < USERNAME_MIN_LEN) {
+ setError(t('register.err_username_len', { n: USERNAME_MIN_LEN })); return;
+ }
if (password !== confirm) { setError(t('register.err_mismatch')); return; }
if (password.length < PASSWORD_MIN_LEN) {
setError(t('register.err_min_len', { n: PASSWORD_MIN_LEN })); return;
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
index 066994c..065e58e 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
@@ -114,6 +114,7 @@ export default {
'welcome.download': 'Herunterladen (Beta)',
'welcome.legal': 'Rechtliche Hinweise',
'register.err_mismatch': 'Die Passwörter stimmen nicht überein',
+ 'register.err_username_len': 'Der Benutzername muss mindestens {n} Zeichen lang sein.',
'register.err_min_len': {
one: 'Verwenden Sie mindestens {n} Zeichen',
other: 'Verwenden Sie mindestens {n} Zeichen',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
index 89b52a6..83a39e7 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
@@ -117,6 +117,7 @@ export default {
'welcome.download': 'Download (beta)',
'welcome.legal': 'Legal information',
'register.err_mismatch': 'Passwords do not match',
+ 'register.err_username_len': 'Username must be at least {n} characters.',
'register.err_min_len': {
one: 'Use at least {n} character',
other: 'Use at least {n} characters',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
index b5c8ad9..73757d0 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
@@ -113,6 +113,7 @@ export default {
'welcome.download': 'Descargar (beta)',
'welcome.legal': 'Información legal',
'register.err_mismatch': 'Las contraseñas no coinciden',
+ 'register.err_username_len': 'El nombre de usuario debe tener al menos {n} caracteres.',
'register.err_min_len': {
one: 'Use al menos {n} carácter',
other: 'Use al menos {n} caracteres',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
index 689b24c..35bce2c 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
@@ -113,6 +113,7 @@ export default {
'welcome.download': 'Télécharger (bêta)',
'welcome.legal': 'Informations légales',
'register.err_mismatch': 'Les mots de passe ne correspondent pas',
+ 'register.err_username_len': 'Le nom d\'utilisateur doit contenir au moins {n} caractères.',
'register.err_min_len': {
one: 'Utilisez au moins {n} caractère',
other: 'Utilisez au moins {n} caractères',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
index fc7dbb2..edc0d97 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
@@ -114,6 +114,7 @@ export default {
'welcome.download': 'Scarica (beta)',
'welcome.legal': 'Note legali',
'register.err_mismatch': 'Le password non coincidono',
+ 'register.err_username_len': 'Il nome utente deve contenere almeno {n} caratteri.',
'register.err_min_len': {
one: 'Usi almeno {n} carattere',
other: 'Usi almeno {n} caratteri',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
index da477cd..8667d20 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
@@ -114,6 +114,7 @@ export default {
'welcome.download': 'ダウンロード(ベータ版)',
'welcome.legal': '法的情報',
'register.err_mismatch': 'パスワードが一致しません',
+ 'register.err_username_len': 'ユーザー名は{n}文字以上にしてください。',
'register.err_min_len': {
other: '{n} 文字以上でご入力ください',
},
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
index a8d67e5..fc2eccb 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
@@ -114,6 +114,7 @@ export default {
'welcome.download': 'Downloaden (bèta)',
'welcome.legal': 'Juridische informatie',
'register.err_mismatch': 'De wachtwoorden komen niet overeen',
+ 'register.err_username_len': 'De gebruikersnaam moet minstens {n} tekens lang zijn.',
'register.err_min_len': {
one: 'Gebruik minstens {n} teken',
other: 'Gebruik minstens {n} tekens',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
index ae98a65..af65489 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
@@ -117,6 +117,7 @@ export default {
'welcome.download': 'Pobierz (beta)',
'welcome.legal': 'Informacje prawne',
'register.err_mismatch': 'Hasła nie są zgodne',
+ 'register.err_username_len': 'Nazwa użytkownika musi mieć co najmniej {n} znaków.',
'register.err_min_len': {
one: 'Proszę użyć co najmniej {n} znaku',
few: 'Proszę użyć co najmniej {n} znaków',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
index bd57f50..65e1ec1 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
@@ -115,6 +115,7 @@ export default {
'welcome.download': 'Baixar (beta)',
'welcome.legal': 'Informações legais',
'register.err_mismatch': 'As senhas não coincidem',
+ 'register.err_username_len': 'O nome de usuário deve ter pelo menos {n} caracteres.',
'register.err_min_len': {
one: 'Use pelo menos {n} caractere',
other: 'Use pelo menos {n} caracteres',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
index 918b0ad..87257b4 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
@@ -114,6 +114,7 @@ export default {
'welcome.download': '下载(测试版)',
'welcome.legal': '法律信息',
'register.err_mismatch': '两次输入的密码不一致',
+ 'register.err_username_len': '用户名至少需要 {n} 个字符。',
'register.err_min_len': {
other: '请至少使用 {n} 个字符',
},