Backend: - Add rate limiting to login (5 attempts / 5 min window) - Add secure flag to session cookies with helper function - Add PIN min-length validation via Pydantic field_validator - Fix naive datetime usage in todos.py (datetime.now() not UTC) - Disable SQLAlchemy echo in production - Remove auto-commit from get_db to prevent double commits - Add lower bound filter to upcoming events query - Add SECRET_KEY default warning on startup - Remove create_all from lifespan (Alembic handles migrations) Frontend: - Fix ReminderForm remind_at slice for datetime-local input - Add window.confirm() dialogs on all destructive actions - Redirect authenticated users away from login screen - Replace error: any with getErrorMessage helper in LockScreen Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
918 B
Python
41 lines
918 B
Python
from pydantic import BaseModel, ConfigDict, field_validator
|
|
from datetime import datetime
|
|
|
|
|
|
class SettingsCreate(BaseModel):
|
|
pin: str
|
|
|
|
@field_validator('pin')
|
|
@classmethod
|
|
def pin_min_length(cls, v: str) -> str:
|
|
if len(v) < 4:
|
|
raise ValueError('PIN must be at least 4 characters')
|
|
return v
|
|
|
|
|
|
class SettingsUpdate(BaseModel):
|
|
accent_color: str | None = None
|
|
upcoming_days: int | None = None
|
|
|
|
|
|
class SettingsResponse(BaseModel):
|
|
id: int
|
|
accent_color: str
|
|
upcoming_days: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ChangePinRequest(BaseModel):
|
|
old_pin: str
|
|
new_pin: str
|
|
|
|
@field_validator('new_pin')
|
|
@classmethod
|
|
def new_pin_min_length(cls, v: str) -> str:
|
|
if len(v) < 4:
|
|
raise ValueError('New PIN must be at least 4 characters')
|
|
return v
|