Download src/schemas/auth.py from arimatch1/crewhub: direct link, hf CLI and curl.
- Browser
- Download file 2.63 kB
-
https://huggingface.co/spaces/arimatch1/crewhub/resolve/main/src/schemas/auth.py
- Command line
-
hf download hf://spaces/arimatch1/crewhub/src/schemas/auth.py
-
curl -L -o auth.py https://huggingface.co/spaces/arimatch1/crewhub/resolve/main/src/schemas/auth.py
2.63 kB
| # Copyright (c) 2026 CrewHub. All rights reserved. | |
| # Proprietary and confidential. See LICENSE for details. | |
| import re | |
| from uuid import UUID | |
| from datetime import datetime | |
| from pydantic import BaseModel, ConfigDict, EmailStr, Field, field_validator | |
| class UserCreate(BaseModel): | |
| email: EmailStr | |
| password: str = Field(min_length=8) | |
| name: str = Field(max_length=100) | |
| def sanitize_name(cls, v: str) -> str: | |
| v = re.sub(r"<[^>]*>", "", v).strip() | |
| if not v: | |
| raise ValueError("Name cannot be empty or only HTML tags") | |
| return v | |
| def password_strength(cls, v: str) -> str: | |
| if not re.search(r"[A-Z]", v): | |
| raise ValueError("Password must contain at least one uppercase letter") | |
| if not re.search(r"[a-z]", v): | |
| raise ValueError("Password must contain at least one lowercase letter") | |
| if not re.search(r"\d", v): | |
| raise ValueError("Password must contain at least one digit") | |
| return v | |
| class UserResponse(BaseModel): | |
| model_config = ConfigDict(from_attributes=True) | |
| id: UUID | |
| email: str | |
| name: str | |
| is_active: bool | |
| is_admin: bool = False | |
| admin_role: str | None = None | |
| onboarding_completed: bool = False | |
| account_tier: str = "free" | |
| daily_spend_limit: float | None = None | |
| interests: list[str] = [] | |
| created_at: datetime | |
| class OnboardingComplete(BaseModel): | |
| name: str | None = Field(None, max_length=100) | |
| interests: list[str] = [] | |
| def sanitize_name(cls, v: str | None) -> str | None: | |
| if v is None: | |
| return v | |
| v = re.sub(r"<[^>]*>", "", v).strip() | |
| if not v: | |
| raise ValueError("Name cannot be empty or only HTML tags") | |
| return v | |
| class UserUpdate(BaseModel): | |
| name: str | None = Field(None, max_length=100) | |
| email: EmailStr | None = None | |
| daily_spend_limit: float | None = Field(None, ge=0, le=100_000) | |
| def sanitize_name(cls, v: str | None) -> str | None: | |
| if v is None: | |
| return v | |
| # Strip HTML tags to prevent stored XSS | |
| v = re.sub(r"<[^>]*>", "", v).strip() | |
| if not v: | |
| raise ValueError("Name cannot be empty or only HTML tags") | |
| return v | |
| class Token(BaseModel): | |
| access_token: str | |
| token_type: str = "bearer" | |
| class ApiKeyCreate(BaseModel): | |
| name: str | |
| class ApiKeyResponse(BaseModel): | |
| key: str | |
| name: str | |
| created_at: datetime | |