mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 16:51:38 +10:00
fix: account deletion error for users without two factor authentication
This commit is contained in:
@ -113,10 +113,26 @@ export const ProfileForm = ({ className, user }: ProfileFormProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDeleteAccount = async () => {
|
const onDeleteAccount = async (hasTwoFactorAuthentication: boolean) => {
|
||||||
try {
|
try {
|
||||||
|
if (!hasTwoFactorAuthentication) {
|
||||||
|
await deleteAccount();
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: 'Account deleted',
|
||||||
|
description: 'Your account has been deleted successfully.',
|
||||||
|
duration: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
|
await signOut({ callbackUrl: '/' });
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { token } = deleteAccountTwoFactorTokenForm.getValues();
|
const { token } = deleteAccountTwoFactorTokenForm.getValues();
|
||||||
|
|
||||||
|
console.log(token);
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error('Please enter your Two Factor Authentication token.');
|
throw new Error('Please enter your Two Factor Authentication token.');
|
||||||
}
|
}
|
||||||
@ -273,7 +289,7 @@ export const ProfileForm = ({ className, user }: ProfileFormProps) => {
|
|||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button
|
<Button
|
||||||
onClick={onDeleteAccount}
|
onClick={async () => onDeleteAccount(hasTwoFactorAuthentication)}
|
||||||
loading={isDeletingAccount}
|
loading={isDeletingAccount}
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user