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

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