INNER CODE UNIT · Python
_require_user
iLearn-Lab/NovelClaw · apps/multiagent/local_web_portal/app/main.py:151
def _require_user(request: Request, db: Session) -> User:
user = _current_user(request, db)
if not user:
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Unauthorized")
return user
def _is_shared_portal_path(path: str) -> bool:
return any(path == item or path.startswith(f"{item}/") for item in SHARED_PORTAL_PATHS)
def _shared_path(path: str) -> str:
normalized = (path or "").strip() or "/"
normalized = normalized if normalized.startswith("/") else f"/{normalized}"
if _is_shared_portal_path(normalized) and settings.shared_portal_url:
return f"{settings.shared_portal_url}{normalized}"
return normalized