From ddb7627c30514203ff1c99cb4a18d43f04e97f8f Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 16 Jul 2024 21:31:08 -0700 Subject: [PATCH] fix(internal_user_endpoints.py): delete associated invitation links before deleting user in `/user/delete` Fixes https://github.com/BerriAI/litellm/issues/4740 --- .../proxy/management_endpoints/internal_user_endpoints.py | 5 +++++ litellm/proxy/management_endpoints/team_endpoints.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/management_endpoints/internal_user_endpoints.py b/litellm/proxy/management_endpoints/internal_user_endpoints.py index 0914659689..280ff2ad20 100644 --- a/litellm/proxy/management_endpoints/internal_user_endpoints.py +++ b/litellm/proxy/management_endpoints/internal_user_endpoints.py @@ -778,6 +778,11 @@ async def delete_user( 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 deleted_users = await prisma_client.db.litellm_usertable.delete_many( where={"user_id": {"in": data.user_ids}} diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py index b85ddb6ca0..0d2fb9925d 100644 --- a/litellm/proxy/management_endpoints/team_endpoints.py +++ b/litellm/proxy/management_endpoints/team_endpoints.py @@ -748,7 +748,9 @@ async def team_info( 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( status_code=status.HTTP_403_FORBIDDEN, detail="key not allowed to access this team's info",