MyMidas/backend/app/schemas/auth.py
megaproxy 61a7884ee5 Initial commit: MyMidas personal finance tracker
Full-stack self-hosted finance app with FastAPI backend and React frontend.

Features:
- Accounts, transactions, budgets, investments with GBP base currency
- CSV import with auto-detection for 10 UK bank formats
- ML predictions: spending forecast, net worth projection, Monte Carlo
- 7 selectable themes (Obsidian, Arctic, Midnight, Vault, Terminal, Synthwave, Ledger)
- Receipt/document attachments on transactions (JPEG, PNG, WebP, PDF)
- AES-256-GCM field encryption, RS256 JWT, TOTP 2FA, RLS, audit log
- Encrypted nightly backups + key rotation script
- Mobile-responsive layout with bottom nav

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 11:56:10 +00:00

64 lines
1.4 KiB
Python

import uuid
from datetime import datetime
from pydantic import BaseModel, EmailStr, field_validator
class RegisterRequest(BaseModel):
email: EmailStr
password: str
display_name: str
@field_validator("password")
@classmethod
def password_strength(cls, v: str) -> str:
if len(v) < 12:
raise ValueError("Password must be at least 12 characters")
if not any(c.isupper() for c in v):
raise ValueError("Password must contain an uppercase letter")
if not any(c.isdigit() for c in v):
raise ValueError("Password must contain a digit")
return v
class LoginRequest(BaseModel):
email: EmailStr
password: str
class TOTPChallengeResponse(BaseModel):
totp_required: bool = True
challenge_token: str
class TOTPLoginRequest(BaseModel):
challenge_token: str
totp_code: str
class TokenResponse(BaseModel):
access_token: str
token_type: str = "bearer"
expires_in: int # seconds
class TOTPSetupResponse(BaseModel):
secret: str
qr_code_png_b64: str
backup_codes: list[str]
class TOTPVerifyRequest(BaseModel):
code: str
class SessionInfo(BaseModel):
id: uuid.UUID
ip_address: str | None
user_agent: str | None
last_active_at: datetime
expires_at: datetime
created_at: datetime
is_current: bool = False
model_config = {"from_attributes": True}