diff --git a/src/argilla_server/apis/v1/handlers/users.py b/src/argilla_server/apis/v1/handlers/users.py index daf0c1bb..5860631f 100644 --- a/src/argilla_server/apis/v1/handlers/users.py +++ b/src/argilla_server/apis/v1/handlers/users.py @@ -14,30 +14,34 @@ from uuid import UUID -from fastapi import APIRouter, Depends, HTTPException, Security, status +from fastapi import APIRouter, Depends, HTTPException, Request, Security, status from sqlalchemy.ext.asyncio import AsyncSession +from argilla_server import models, telemetry from argilla_server.contexts import accounts from argilla_server.database import get_async_db from argilla_server.models import User from argilla_server.policies import UserPolicyV1, authorize -from argilla_server.schemas.v1.users import User as UserSchema +from argilla_server.schemas.v1.users import User from argilla_server.schemas.v1.workspaces import Workspaces from argilla_server.security import auth router = APIRouter(tags=["users"]) -@router.get("/me", response_model=UserSchema) -async def get_current_user(current_user: User = Security(auth.get_current_user)): - # TODO: Should we add telemetry.track_login? +@router.get("/me", response_model=User) +async def get_current_user(request: Request, current_user: models.User = Security(auth.get_current_user)): + await telemetry.track_login(request, current_user) return current_user @router.get("/users/{user_id}/workspaces", response_model=Workspaces) async def list_user_workspaces( - *, db: AsyncSession = Depends(get_async_db), user_id: UUID, current_user: User = Security(auth.get_current_user) + *, + db: AsyncSession = Depends(get_async_db), + user_id: UUID, + current_user: models.User = Security(auth.get_current_user), ): await authorize(current_user, UserPolicyV1.list_workspaces)