mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-25 21:36:52 +08:00
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
24 lines
772 B
Python
24 lines
772 B
Python
"""User router for OpenHands Server. For the moment, this simply implements the /me endpoint."""
|
|
|
|
from fastapi import APIRouter, HTTPException, status
|
|
|
|
from openhands.app_server.config import depends_user_context
|
|
from openhands.app_server.user.user_context import UserContext
|
|
from openhands.app_server.user.user_models import UserInfo
|
|
|
|
router = APIRouter(prefix='/users', tags=['User'])
|
|
user_dependency = depends_user_context()
|
|
|
|
# Read methods
|
|
|
|
|
|
@router.get('/me')
|
|
async def get_current_user(
|
|
user_context: UserContext = user_dependency,
|
|
) -> UserInfo:
|
|
"""Get the current authenticated user."""
|
|
user = await user_context.get_user_info()
|
|
if user is None:
|
|
raise HTTPException(status.HTTP_401_UNAUTHORIZED, detail='Not authenticated')
|
|
return user
|