Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
feat: add telemetry.track_login call
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcalvo committed May 6, 2024
1 parent 6e4b910 commit 06bd520
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/argilla_server/apis/v1/handlers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 06bd520

Please sign in to comment.