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..2e1087380 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,8 @@ import { DialogTitle, DialogTrigger, } from '@documenso/ui/primitives/dialog'; +import { Input } from '@documenso/ui/primitives/input'; +import { Label } from '@documenso/ui/primitives/label'; import { useToast } from '@documenso/ui/primitives/use-toast'; export type DeleteAccountDialogProps = { @@ -28,6 +32,8 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp const hasTwoFactorAuthentication = user.twoFactorEnabled; + const [enteredEmail, setEnteredEmail] = useState(''); + const { mutateAsync: deleteAccount, isLoading: isDeletingAccount } = trpc.profile.deleteAccount.useMutation(); @@ -76,10 +82,11 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp
- + setEnteredEmail('')}> + Delete Account @@ -105,12 +112,29 @@ export const DeleteAccountDialog = ({ className, user }: DeleteAccountDialogProp + {!hasTwoFactorAuthentication && ( +
+ + + setEnteredEmail(e.target.value)} + /> +
+ )} diff --git a/packages/app-tests/e2e/test-delete-user.spec.ts b/packages/app-tests/e2e/test-delete-user.spec.ts index beae6eb09..6eb72bad9 100644 --- a/packages/app-tests/e2e/test-delete-user.spec.ts +++ b/packages/app-tests/e2e/test-delete-user.spec.ts @@ -16,6 +16,8 @@ test('delete user', async ({ page }) => { }); await page.getByRole('button', { name: 'Delete Account' }).click(); + await page.getByLabel('Confirm Email').fill(user.email); + await expect(page.getByRole('button', { name: 'Confirm Deletion' })).not.toBeDisabled(); await page.getByRole('button', { name: 'Confirm Deletion' }).click(); await page.waitForURL(`${WEBAPP_BASE_URL}/signin`);