fix: Allow email addresses as Nextcloud admin username
Build and Push Docker Image / test (push) Successful in 59s Details
Build and Push Docker Image / build (push) Successful in 1m12s Details

The validation was too restrictive, only allowing alphanumeric usernames.
Now accepts both:
- Standard usernames (letters, numbers, underscores)
- Valid email addresses

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt 2025-12-09 14:13:08 +01:00
parent 0869787755
commit d85ab9c493
2 changed files with 10 additions and 4 deletions

View File

@ -15,7 +15,11 @@
"Bash(python:*)", "Bash(python:*)",
"Bash(git init:*)", "Bash(git init:*)",
"Bash(git remote add:*)", "Bash(git remote add:*)",
"Bash(git add:*)" "Bash(git add:*)",
"Bash(git commit -m \"$(cat <<''EOF''\nInitial commit: LetsBe Cloud Orchestrator\n\nFeatures:\n- FastAPI backend with SQLAlchemy 2.0 async ORM\n- Tenant management (CRUD operations)\n- Task management with types: FILE_WRITE, ENV_UPDATE, DOCKER_RELOAD, COMPOSITE\n- Agent registration, heartbeat, and task claiming (/tasks/next)\n- Chatwoot deployment playbook (COMPOSITE task with ENV_UPDATE + DOCKER_RELOAD)\n- Alembic migrations for Postgres\n- Docker Compose setup for local development\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")",
"Bash(git push:*)",
"Bash(git remote set-url:*)",
"Bash(git commit:*)"
], ],
"deny": [], "deny": [],
"ask": [] "ask": []

View File

@ -68,10 +68,12 @@ class NextcloudInitialSetupRequest(BaseModel):
@field_validator("admin_username") @field_validator("admin_username")
@classmethod @classmethod
def validate_username(cls, v: str) -> str: def validate_username(cls, v: str) -> str:
"""Validate that username is alphanumeric (with underscores allowed).""" """Validate that username is alphanumeric or a valid email address."""
if not re.match(r"^[a-zA-Z][a-zA-Z0-9_]*$", v): username_pattern = r"^[a-zA-Z][a-zA-Z0-9_]*$"
email_pattern = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
if not (re.match(username_pattern, v) or re.match(email_pattern, v)):
raise ValueError( raise ValueError(
"Username must start with a letter and contain only letters, numbers, and underscores" "Username must be alphanumeric (starting with a letter) or a valid email address"
) )
return v return v