mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
chore: use email confirmation
This commit is contained in:
@ -30,9 +30,9 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp
|
|||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
const hasTwoFactorAuthentication = user.twoFactorEnabled;
|
const hasTwoFactorAuthentication = user.twoFactorEnabled;
|
||||||
const username = user.name!;
|
const userEmail = user.email;
|
||||||
|
|
||||||
const [enteredUsername, setEnteredUsername] = useState<string>('');
|
const [enteredEmail, setEnteredEmail] = useState<string>('');
|
||||||
|
|
||||||
const { mutateAsync: deleteAccount, isLoading: isDeletingAccount } =
|
const { mutateAsync: deleteAccount, isLoading: isDeletingAccount } =
|
||||||
trpc.profile.deleteAccount.useMutation();
|
trpc.profile.deleteAccount.useMutation();
|
||||||
@ -82,7 +82,7 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-shrink-0">
|
<div className="flex-shrink-0">
|
||||||
<Dialog onOpenChange={() => setEnteredUsername('')}>
|
<Dialog onOpenChange={() => setEnteredEmail('')}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button variant="destructive">Delete Account</Button>
|
<Button variant="destructive">Delete Account</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
@ -111,7 +111,7 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp
|
|||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
{!hasTwoFactorAuthentication && (
|
{!hasTwoFactorAuthentication && (
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Please type <span className="font-semibold">{username}</span> to confirm.
|
Please type <span className="font-semibold">{userEmail}</span> to confirm.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
)}
|
)}
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
@ -120,9 +120,8 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp
|
|||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
value={enteredUsername}
|
value={enteredEmail}
|
||||||
onChange={(e) => setEnteredUsername(e.target.value)}
|
onChange={(e) => setEnteredEmail(e.target.value)}
|
||||||
onPaste={(e) => e.preventDefault()}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -133,7 +132,7 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp
|
|||||||
onClick={onDeleteAccount}
|
onClick={onDeleteAccount}
|
||||||
loading={isDeletingAccount}
|
loading={isDeletingAccount}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
disabled={hasTwoFactorAuthentication || enteredUsername !== username}
|
disabled={hasTwoFactorAuthentication || enteredEmail !== userEmail}
|
||||||
>
|
>
|
||||||
{isDeletingAccount ? (
|
{isDeletingAccount ? (
|
||||||
'Deleting account...'
|
'Deleting account...'
|
||||||
|
|||||||
Reference in New Issue
Block a user