fix: Allow user account deletion without SMTP setup, closes #6107

This commit is contained in:
Tom Moor
2024-01-20 10:12:10 -05:00
parent b482654c66
commit 2f2113adb8
3 changed files with 11 additions and 5 deletions

View File

@@ -42,7 +42,7 @@ function Preferences() {
const showDeleteAccount = () => {
dialogs.openModal({
title: t("Delete account"),
content: <UserDelete />,
content: <UserDelete onSubmit={dialogs.closeAllModals} />,
isCentered: true,
});
};

View File

@@ -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;

View File

@@ -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;