diff --git a/apps/web/src/app/(dashboard)/settings/profile/delete-account-dialog.tsx b/apps/web/src/app/(dashboard)/settings/profile/delete-account-dialog.tsx index e9cc885e9..2cb60f4a7 100644 --- a/apps/web/src/app/(dashboard)/settings/profile/delete-account-dialog.tsx +++ b/apps/web/src/app/(dashboard)/settings/profile/delete-account-dialog.tsx @@ -1,5 +1,7 @@ 'use client'; +import { useState } from 'react'; + import { signOut } from 'next-auth/react'; import type { User } from '@documenso/prisma/client'; @@ -16,6 +18,7 @@ import { DialogTitle, DialogTrigger, } from '@documenso/ui/primitives/dialog'; +import { Input } from '@documenso/ui/primitives/input'; import { useToast } from '@documenso/ui/primitives/use-toast'; export type DeleteAccountDialogProps = { @@ -27,6 +30,9 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp const { toast } = useToast(); const hasTwoFactorAuthentication = user.twoFactorEnabled; + const username = user.name!; + + const [enteredUsername, setEnteredUsername] = useState(''); const { mutateAsync: deleteAccount, isLoading: isDeletingAccount } = trpc.profile.deleteAccount.useMutation(); @@ -76,7 +82,7 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp
- + setEnteredUsername('')}> @@ -103,17 +109,44 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp , along with all of your completed documents, signatures, and all other resources belonging to your Account. + {!hasTwoFactorAuthentication && ( + + Please type {username} to confirm. + + )} + {!hasTwoFactorAuthentication && ( +
+ setEnteredUsername(e.target.value)} + onPaste={(e) => e.preventDefault()} + /> +
+ )} - + {!hasTwoFactorAuthentication && ( + + )}