mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
fix(projects): query litellm_usertable.teams for membership in list/info endpoints
This commit is contained in:
parent
740bb44796
commit
294c44f3b7
1 changed files with 13 additions and 18 deletions
|
|
@ -853,14 +853,11 @@ async def project_info(
|
|||
is_team_member = False
|
||||
|
||||
if project.team_id and user_api_key_dict.user_id:
|
||||
team = await prisma_client.db.litellm_teamtable.find_unique(
|
||||
where={"team_id": project.team_id}
|
||||
user_row = await prisma_client.db.litellm_usertable.find_unique(
|
||||
where={"user_id": user_api_key_dict.user_id}
|
||||
)
|
||||
if team:
|
||||
is_team_member = (
|
||||
user_api_key_dict.user_id in team.admins
|
||||
or user_api_key_dict.user_id in team.members
|
||||
)
|
||||
if user_row and user_row.teams:
|
||||
is_team_member = project.team_id in user_row.teams
|
||||
|
||||
if not (is_admin or is_team_member):
|
||||
raise HTTPException(
|
||||
|
|
@ -911,17 +908,15 @@ async def list_projects(
|
|||
include={"litellm_budget_table": True, "object_permission": True}
|
||||
)
|
||||
else:
|
||||
# Get projects for teams the user belongs to
|
||||
user_teams = await prisma_client.db.litellm_teamtable.find_many(
|
||||
where={
|
||||
"OR": [
|
||||
{"members": {"has": user_api_key_dict.user_id}},
|
||||
{"admins": {"has": user_api_key_dict.user_id}},
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
team_ids = [team.team_id for team in user_teams]
|
||||
# Get team IDs from the user's own record — litellm_usertable.teams
|
||||
# is the authoritative membership list (populated by team_member_add).
|
||||
team_ids: List[str] = []
|
||||
if user_api_key_dict.user_id:
|
||||
user_row = await prisma_client.db.litellm_usertable.find_unique(
|
||||
where={"user_id": user_api_key_dict.user_id}
|
||||
)
|
||||
if user_row and user_row.teams:
|
||||
team_ids = user_row.teams
|
||||
|
||||
projects = await prisma_client.db.litellm_projecttable.find_many(
|
||||
where={"team_id": {"in": team_ids}},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue