🧙♂️ Transform LifeRPG into The Wizard's Grimoire - Production-Ready Application
✨ Major Features Added: - Complete magical theming and rebranding from LifeRPG to The Wizard's Grimoire - Production-grade React frontend with Tailwind CSS v4 and magical aesthetics - Comprehensive analytics dashboard with Recharts integration (ScryingPortal) - Push notifications system with PWA service worker support - Drag & drop functionality using @dnd-kit for habit reordering - Social features with friends system and leaderboards - Performance optimization tools and monitoring - Mobile app enhancement with PWA installation support 🏗️ Technical Infrastructure: - Advanced service worker with offline support and background sync - Zustand state management for scalable application state - Production-ready UI component system with enhanced Button, Card, Input - Progressive Web App (PWA) with manifest and app installation - FastAPI backend with comprehensive API endpoints - Docker containerization and CI/CD pipeline setup 📱 Progressive Web App Features: - Offline functionality with intelligent caching - Push notification support for habit reminders - App installation on mobile and desktop platforms - Background sync for offline data management - Performance monitoring and optimization tools 🎨 User Experience: - Magical wizard/grimoire theming throughout application - Responsive design optimized for all device sizes - Drag & drop habit management with smooth animations - Interactive analytics with multiple chart types - Social connectivity with friends and competitive features - Comprehensive notification and performance settings 🔧 Developer Experience: - Modern development stack with Vite and React - Comprehensive testing setup and CI/CD pipelines - Code quality tools with pre-commit hooks - Docker development environment - Detailed documentation and implementation guides This represents a complete transformation from prototype to production-ready application with enterprise-grade features and magical user experience.
This commit is contained in:
+17
-9
@@ -1,5 +1,7 @@
|
||||
from fastapi import HTTPException, Depends, Request
|
||||
from .auth import get_current_user
|
||||
from auth import get_current_user
|
||||
from db import get_db
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
||||
# Role hierarchy for comparisons
|
||||
@@ -7,16 +9,22 @@ HIERARCHY = {'user': 1, 'moderator': 2, 'admin': 3}
|
||||
|
||||
|
||||
def require_role(min_role: str):
|
||||
"""FastAPI dependency that enforces a minimum role on the calling user."""
|
||||
def _dep(user=Depends(get_current_user)):
|
||||
"""FastAPI dependency that enforces a minimum role on the calling user.
|
||||
|
||||
This dependency requires the `get_current_user` dependency which in turn
|
||||
requires an injected DB session via `get_db` to enforce strict session usage.
|
||||
"""
|
||||
def _dep(request: Request, db: Session = Depends(get_db)):
|
||||
user = get_current_user(request, db=db)
|
||||
if HIERARCHY.get(user.role or 'user', 0) < HIERARCHY.get(min_role, 0):
|
||||
raise HTTPException(status_code=403, detail='insufficient role')
|
||||
return user
|
||||
return _dep
|
||||
|
||||
|
||||
def require_admin(user=Depends(get_current_user)):
|
||||
if HIERARCHY.get(user.role or 'user', 0) < HIERARCHY.get('admin'):
|
||||
def require_admin(request: Request, db: Session = Depends(get_db)):
|
||||
user = get_current_user(request, db=db)
|
||||
if HIERARCHY.get(user.role or 'user', 0) < HIERARCHY.get('admin', 0):
|
||||
raise HTTPException(status_code=403, detail='admin required')
|
||||
return user
|
||||
|
||||
@@ -24,11 +32,11 @@ def require_admin(user=Depends(get_current_user)):
|
||||
def require_owner_or_admin(resource_user_id: int):
|
||||
"""Return a callable that can be used inline to check ownership/admin status.
|
||||
|
||||
Note: FastAPI path param injection into dependency factories is complex; for
|
||||
simplicity endpoints can call this helper with the resource owner id.
|
||||
The returned callable expects a `Request` and an injected `db` (via Depends)
|
||||
so that `get_current_user` is always called with a proper session.
|
||||
"""
|
||||
def _inner(request: Request = None):
|
||||
user = get_current_user(request)
|
||||
def _inner(request: Request = None, db: Session = Depends(get_db)):
|
||||
user = get_current_user(request, db=db)
|
||||
if user.id == resource_user_id or user.role == 'admin':
|
||||
return user
|
||||
raise HTTPException(status_code=403, detail='must be owner or admin')
|
||||
|
||||
Reference in New Issue
Block a user