343f12259c
Backend: - app/core/sanitize.py: shared sanitize_str, normalize_email, validate_phone, validate_date_of_birth — applied to every user-supplied DB-bound input - app/schemas/user.py: sanitize full_name, normalize email on UserCreate - app/models/profile.py: profiles table (position, phone, dob, address, updated_at) - app/models/user.py: Profile back-ref, is_superuser admin-role comment - app/schemas/profile.py: ProfileRead/ProfileUpdate with full sanitization - app/routers/profile.py: GET+PUT /api/profile/me (lazy profile creation) - app/main.py: register /api/profile router - alembic migration 676084df61d1: create profiles table Frontend: - components/Nav.tsx: shared nav (Dashboard | Profile | Logout) - pages/ProfilePage.tsx: profile view + inline edit form with error handling - pages/DashboardPage.tsx: use Nav component - api/client.ts: ProfileData type, getProfile, updateProfile - App.tsx: /profile private route Security: - scripts/security_check.py: tighter SQL injection patterns (f-string/format/% in execute/query/text()), new SANIT category for raw request→DB patterns Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.2 KiB
2.2 KiB
2026-04-13 — Profile feature + input sanitization
Timestamp: 2026-04-13T02:00:00
Summary
Added shared input sanitization layer applied to all database-bound inputs, introduced the profiles table for personal information (position, phone, date of birth, address), and built the frontend profile page with inline editing and a shared nav bar (Dashboard | Profile | Logout). Admin role flag (is_superuser) confirmed hidden from API. Security check patterns strengthened.
Files Added
backend/app/core/sanitize.py— shared helpers:sanitize_str,normalize_email,validate_phone,validate_date_of_birth; applied to every user-supplied string before it reaches the DBbackend/app/models/profile.py—ProfileORM model (profiles table):user_idFK,phone,date_of_birth,position,address,updated_atbackend/app/schemas/profile.py—ProfileRead/ProfileUpdatePydantic schemas; all fields sanitized via shared helpersbackend/app/routers/profile.py—GET /api/profile/me(lazy-create),PUT /api/profile/mebackend/alembic/versions/676084df61d1_add_profiles_table.py— Alembic migration creating the profiles tablefrontend/src/components/Nav.tsx— shared nav bar: Dashboard, Profile, Logoutfrontend/src/pages/ProfilePage.tsx— profile view + inline edit form; uses TanStack Query for fetch/mutate
Files Modified
backend/app/schemas/user.py— addednormalize_emailandsanitize_strvalidators toUserCreatebackend/app/models/user.py— addedProfileback-reference; added admin-role comment onis_superuserbackend/app/models/__init__.py— exportProfilebackend/app/main.py— register/api/profilerouterfrontend/src/api/client.ts— addedProfileData,ProfileUpdatetypes,getProfile,updateProfilefrontend/src/App.tsx— added/profileprivate routefrontend/src/pages/DashboardPage.tsx— replaced inline logout withNavcomponentscripts/security_check.py— strengthened SQL injection patterns (f-string/format/% in execute, text() without bindparam); added SANIT category for raw request→DB patternsTODO.md— frontend feature items marked completeREADME.md— Current State updated