diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-15 02:16:39 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-15 02:21:01 +0200 |
| commit | bdefcd025604f2c3009fe5e0cc01213c2ba62a6a (patch) | |
| tree | eebd34aa234a9148045ca25b00bf7c8039e00ccf /packages/meshbay-hub/src/meshbay_hub/api/users.py | |
| parent | 027e7d55f3bb57ba5150fd77e8f0114a0baf8d5c (diff) | |
| download | meshbay-bdefcd025604f2c3009fe5e0cc01213c2ba62a6a.tar.gz | |
feat(hub): usernames are at least 8 characters at registration
Existing shorter accounts keep signing in. Test usernames padded to match.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XuNrwLf5EFWCMHzfoEvnpm
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/api/users.py')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/api/users.py | 10 |
1 files changed, 8 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 |