mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 17:13:42 +00:00
Add complete authentication layer: - Pydantic v2 schemas for auth requests/responses and user representation - Auth service with login (account locking, MFA), registration (invitation tokens + domain whitelist), token management, MFA setup/activation, and password change - FastAPI router with 8 endpoints: login, register, refresh, logout, mfa/setup, mfa/verify, change-password, me - Router registered in main.py under /api/auth Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
908 B
Python
39 lines
908 B
Python
"""Pydantic v2 schemas for User responses and mutations."""
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, EmailStr
|
|
|
|
|
|
class UserResponse(BaseModel):
|
|
"""Public representation of a user (returned by API endpoints)."""
|
|
|
|
id: int
|
|
username: str
|
|
email: str
|
|
role: str
|
|
mfa_enabled: bool
|
|
is_active: bool
|
|
last_login: Optional[datetime] = None
|
|
created_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class UserCreate(BaseModel):
|
|
"""Admin-only: create a user directly (bypasses invitation/domain check)."""
|
|
|
|
username: str
|
|
email: EmailStr
|
|
password: str
|
|
role: str = "dak_mitarbeiter"
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
|
"""Admin-only: partial update of user fields."""
|
|
|
|
username: Optional[str] = None
|
|
email: Optional[EmailStr] = None
|
|
role: Optional[str] = None
|
|
is_active: Optional[bool] = None
|