fix(internal_user_endpoints.py): delete associated invitation links before deleting user in /user/delete

Fixes https://github.com/BerriAI/litellm/issues/4740
This commit is contained in:
Krrish Dholakia 2024-07-16 21:31:08 -07:00
parent b04d20d367
commit ddb7627c30
2 changed files with 8 additions and 1 deletions

View file

@ -778,6 +778,11 @@ async def delete_user(
where={"user_id": {"in": data.user_ids}} where={"user_id": {"in": data.user_ids}}
) )
## DELETE ASSOCIATED INVITATION LINKS
await prisma_client.db.litellm_invitationlink.delete_many(
where={"user_id": {"in": data.user_ids}}
)
## DELETE USERS ## DELETE USERS
deleted_users = await prisma_client.db.litellm_usertable.delete_many( deleted_users = await prisma_client.db.litellm_usertable.delete_many(
where={"user_id": {"in": data.user_ids}} where={"user_id": {"in": data.user_ids}}

View file

@ -748,7 +748,9 @@ async def team_info(
detail={"message": "Malformed request. No team id passed in."}, detail={"message": "Malformed request. No team id passed in."},
) )
if user_api_key_dict.team_id or (team_id != user_api_key_dict.team_id): if user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value:
pass
elif user_api_key_dict.team_id or (team_id != user_api_key_dict.team_id):
raise HTTPException( raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN, status_code=status.HTTP_403_FORBIDDEN,
detail="key not allowed to access this team's info", detail="key not allowed to access this team's info",