Implement user authentication and management system with FastAPI
- Added authentication routes for login, registration, password reset, and account deletion in `auth.py`. - Implemented user profile management, including updating user information and changing passwords. - Created dashboard views to display user-specific information and recent activity in `dashboard.py`. - Developed leaderboard views to show team rankings and points in `leaderboard.py`. - Added QR code generation and redemption functionality in `qr.py` and `redeem.py`. - Implemented team management features, allowing users to create and join teams in `teams.py`. - Introduced session debugging utility to assist with session-related issues in `debug_session.py`. - Configured Docker Compose for MySQL database and FastAPI application with environment variables. - Updated requirements.txt to include necessary dependencies for the application.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from pathlib import Path
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
from starlette.templating import _TemplateResponse
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
|
||||
# Create a Jinja2 Environment with the 'jinja2.ext.do' extension
|
||||
class MyJinjaTemplates(Jinja2Templates):
|
||||
def __init__(self, directory: str, **kwargs: Any):
|
||||
super().__init__(directory=directory, **kwargs)
|
||||
self.env.add_extension('jinja2.ext.do')
|
||||
self.env.globals['now'] = datetime.now # Add 'now' function
|
||||
|
||||
# Create templates object that can be imported elsewhere
|
||||
templates = MyJinjaTemplates(directory=str(BASE_DIR / "templates"))
|
||||
|
||||
# Register a context processor to add current_user to all templates
|
||||
templates.env.globals["get_current_user"] = lambda: None # Will be overridden at runtime
|
||||
Reference in New Issue
Block a user