Frontend: - Add progress modals with educational content for analysis and voice cloning - Improve tab navigation in AnalysisPanel (combine Titles, Hook, CTA into one tab) - Fix tab styling to make inactive tabs visible - Fix avatar 'Make Presentable' not updating preview (blob URL handling) - Improve mobile responsiveness for avatar tabs - Clean up verbose console logging (AnalysisPanel, demoMode, RobustCamera) - Add sequential progress messages instead of cycling Backend: - Fix 'Depends object has no attribute get' error in auth and image editing - Use get_session_for_user instead of get_db outside FastAPI DI context - Reduce WARNING logs to DEBUG in audio handler - Add proper emphasis boolean handling in script generation - Add missing fields to PodcastScene and PodcastSceneLine models - Fix voice cloning cost estimate display issue
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from typing import Any, Dict
|
|
|
|
from fastapi import HTTPException, status
|
|
|
|
|
|
def require_authenticated_user(current_user: Dict[str, Any] | None) -> str:
|
|
"""
|
|
Validates the current user dictionary provided by Clerk middleware and
|
|
returns the normalized user_id. Raises HTTP 401 if authentication fails.
|
|
"""
|
|
# Guard against dependency injection issues where Depends object might be passed
|
|
if current_user is None or not isinstance(current_user, dict):
|
|
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Authentication required")
|
|
|
|
# Additional check: ensure it's actually a dict and not a Depends object or other type
|
|
if not hasattr(current_user, 'get') or not callable(getattr(current_user, 'get')):
|
|
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid authentication context")
|
|
|
|
user_id = str(current_user.get("id", "")).strip()
|
|
if not user_id:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
detail="Invalid user ID in authentication token",
|
|
)
|
|
|
|
return user_id
|
|
|
|
|