feat: Initial commit - Task Reporter incident response system
Complete implementation of the production line incident response system (生產線異常即時反應系統) including: Backend (FastAPI): - User authentication with AD integration and session management - Chat room management (create, list, update, members, roles) - Real-time messaging via WebSocket (typing indicators, reactions) - File storage with MinIO (upload, download, image preview) Frontend (React + Vite): - Authentication flow with token management - Room list with filtering, search, and pagination - Real-time chat interface with WebSocket - File upload with drag-and-drop and image preview - Member management and room settings - Breadcrumb navigation - 53 unit tests (Vitest) Specifications: - authentication: AD auth, sessions, JWT tokens - chat-room: rooms, members, templates - realtime-messaging: WebSocket, messages, reactions - file-storage: MinIO integration, file management - frontend-core: React SPA structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
31
app/modules/auth/dependencies.py
Normal file
31
app/modules/auth/dependencies.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""FastAPI dependencies for authentication
|
||||
|
||||
供其他模組引用的 dependency injection 函數
|
||||
"""
|
||||
from fastapi import Request, HTTPException, status
|
||||
|
||||
|
||||
async def get_current_user(request: Request) -> dict:
|
||||
"""Get current authenticated user from request state
|
||||
|
||||
Usage in other modules:
|
||||
from app.modules.auth import get_current_user
|
||||
|
||||
@router.get("/my-endpoint")
|
||||
async def my_endpoint(current_user: dict = Depends(get_current_user)):
|
||||
username = current_user["username"]
|
||||
display_name = current_user["display_name"]
|
||||
...
|
||||
|
||||
Returns:
|
||||
dict: {"id": int, "username": str, "display_name": str}
|
||||
|
||||
Raises:
|
||||
HTTPException: If user not authenticated (middleware should prevent this)
|
||||
"""
|
||||
if not hasattr(request.state, "user"):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED, detail="Authentication required"
|
||||
)
|
||||
|
||||
return request.state.user
|
||||
Reference in New Issue
Block a user