From d1e35c4e6977914d74b396af30066819bf3b8a67 Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Thu, 19 Sep 2024 17:20:50 -0700 Subject: [PATCH] Saml account fastapi deletion (#2512) * saml account fastapi deletion * update error detail --- backend/danswer/server/manage/users.py | 5 ++++- web/src/components/admin/users/SignedUpUserTable.tsx | 3 ++- web/src/lib/admin/users/userMutationFetcher.ts | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/danswer/server/manage/users.py b/backend/danswer/server/manage/users.py index 30b71ef0a6a..e72b85dedad 100644 --- a/backend/danswer/server/manage/users.py +++ b/backend/danswer/server/manage/users.py @@ -33,6 +33,7 @@ from danswer.db.models import AccessToken from danswer.db.models import DocumentSet__User from danswer.db.models import Persona__User +from danswer.db.models import SamlAccount from danswer.db.models import User from danswer.db.models import User__UserGroup from danswer.db.users import get_user_by_email @@ -249,7 +250,9 @@ async def delete_user( db_session=db_session, user_id=user_to_delete.id, ) - + db_session.query(SamlAccount).filter( + SamlAccount.user_id == user_to_delete.id + ).delete() db_session.query(DocumentSet__User).filter( DocumentSet__User.user_id == user_to_delete.id ).delete() diff --git a/web/src/components/admin/users/SignedUpUserTable.tsx b/web/src/components/admin/users/SignedUpUserTable.tsx index cb30e4d89bc..b718221d6c0 100644 --- a/web/src/components/admin/users/SignedUpUserTable.tsx +++ b/web/src/components/admin/users/SignedUpUserTable.tsx @@ -143,7 +143,8 @@ const DeactivaterButton = ({ type: "success", }); }, - onError: (errorMsg) => setPopup({ message: errorMsg, type: "error" }), + onError: (errorMsg) => + setPopup({ message: errorMsg.message, type: "error" }), } ); return ( diff --git a/web/src/lib/admin/users/userMutationFetcher.ts b/web/src/lib/admin/users/userMutationFetcher.ts index d0c090c89ce..3a3e134e967 100644 --- a/web/src/lib/admin/users/userMutationFetcher.ts +++ b/web/src/lib/admin/users/userMutationFetcher.ts @@ -11,6 +11,7 @@ const userMutationFetcher = async ( body: JSON.stringify(body), }).then(async (res) => { if (res.ok) return res.json(); + const errorDetail = (await res.json()).detail; throw Error(errorDetail); });