mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
V1 Integration (#11183)
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>
This commit is contained in:
23
openhands/app_server/user/user_router.py
Normal file
23
openhands/app_server/user/user_router.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user