From 2f2113adb8c3b961a080b38f1faa21b7a96b1fb6 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 20 Jan 2024 10:12:10 -0500 Subject: [PATCH] fix: Allow user account deletion without SMTP setup, closes #6107 --- app/scenes/Settings/Preferences.tsx | 2 +- app/scenes/TeamDelete.tsx | 2 +- app/scenes/UserDelete.tsx | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/scenes/Settings/Preferences.tsx b/app/scenes/Settings/Preferences.tsx index da1f3850f..01d3e81b3 100644 --- a/app/scenes/Settings/Preferences.tsx +++ b/app/scenes/Settings/Preferences.tsx @@ -42,7 +42,7 @@ function Preferences() { const showDeleteAccount = () => { dialogs.openModal({ title: t("Delete account"), - content: , + content: , isCentered: true, }); }; diff --git a/app/scenes/TeamDelete.tsx b/app/scenes/TeamDelete.tsx index 68c73156e..acc4eeb7b 100644 --- a/app/scenes/TeamDelete.tsx +++ b/app/scenes/TeamDelete.tsx @@ -58,7 +58,7 @@ function TeamDelete({ onSubmit }: Props) { ); const inputProps = register("code", { - required: true, + required: env.EMAIL_ENABLED, }); const appName = env.APP_NAME; const workspaceName = team.name; diff --git a/app/scenes/UserDelete.tsx b/app/scenes/UserDelete.tsx index 234448e42..8a60dfaa4 100644 --- a/app/scenes/UserDelete.tsx +++ b/app/scenes/UserDelete.tsx @@ -14,7 +14,12 @@ type FormData = { code: string; }; -function UserDelete() { +type Props = { + /** Callback to close the dialog when user deletion completes. */ + onSubmit: () => void; +}; + +function UserDelete({ onSubmit }: Props) { const [isWaitingCode, setWaitingCode] = React.useState(false); const { auth } = useStores(); const { t } = useTranslation(); @@ -31,11 +36,12 @@ function UserDelete() { try { await auth.requestDeleteUser(); setWaitingCode(true); + onSubmit(); } catch (err) { toast.error(err.message); } }, - [auth] + [auth, onSubmit] ); const handleSubmit = React.useCallback( @@ -51,7 +57,7 @@ function UserDelete() { ); const inputProps = register("code", { - required: true, + required: env.EMAIL_ENABLED, }); const appName = env.APP_NAME;