Files
leocrm/app/schemas/auth.py
T
Agent Zero 825d638130 Phase 3: Fix medium-priority issues (M1-M4, M6)
M1: Password complexity validation (min 8 chars, uppercase, lowercase, digit)
M2: Remove is_system_admin from login response (prevent role leaking)
M3: Permission cache invalidates on DB error instead of using stale data
M4: .env.docker.example already fixed in B9 (SECRET_KEY, FRONTEND_URL, SMTP)
M6: Frontend test setup auto-wraps with QueryClientProvider (fixes ~29 test failures)

Remaining: M5 (frontend component integration — WelcomeDialog, SavedFilterBar, etc.)
2026-07-26 20:51:40 +02:00

44 lines
1.3 KiB
Python

"""Auth schemas."""
from __future__ import annotations
from pydantic import BaseModel, EmailStr, Field, field_validator
from app.schemas.user import _validate_password_complexity
class LoginRequest(BaseModel):
email: EmailStr = Field(..., examples=["admin@leocrm.local"])
password: str = Field(..., min_length=1, examples=["secure-password"])
tenant_slug: str | None = Field(None, description="Tenant slug to select tenant at login", examples=["tenant-a"])
class PasswordResetRequest(BaseModel):
email: EmailStr
class PasswordResetConfirm(BaseModel):
token: str = Field(..., min_length=1)
new_password: str = Field(..., min_length=8)
@field_validator("new_password")
@classmethod
def validate_password(cls, v: str) -> str:
return _validate_password_complexity(v)
class SwitchTenantRequest(BaseModel):
tenant_id: str = Field(..., min_length=1)
class AuthResponse(BaseModel):
user_id: str = Field(..., examples=["550e8400-e29b-41d4-a716-446655440000"])
email: str = Field(..., examples=["admin@leocrm.local"])
name: str = Field(..., examples=["Admin User"])
role: str = Field(..., examples=["admin"])
tenant_id: str = Field(..., examples=["550e8400-e29b-41d4-a716-446655440001"])
tenant_name: str | None = Field(None, examples=["Acme GmbH"])
class MessageResponse(BaseModel):
message: str