Fix account deletion flow

This commit is contained in:
gpt-engineer-app[bot]
2025-10-29 22:46:49 +00:00
parent 2918f9d280
commit a2cb037410
8 changed files with 143 additions and 28 deletions

View File

@@ -70,6 +70,18 @@ serve(async (req) => {
throw new Error('No pending deletion request found');
}
// Check if there's already a confirmed request
const { data: confirmedRequest } = await supabaseClient
.from('account_deletion_requests')
.select('*')
.eq('user_id', user.id)
.eq('status', 'confirmed')
.maybeSingle();
if (confirmedRequest) {
throw new Error('You already have a confirmed deletion request. Your account is scheduled for deletion.');
}
// Verify confirmation code
if (deletionRequest.confirmation_code !== confirmation_code) {
throw new Error('Invalid confirmation code');
@@ -141,7 +153,10 @@ serve(async (req) => {
<li>✓ To cancel, log in and visit your account settings</li>
</ul>
<p>If you take no action, your account will be automatically deleted after the 14-day waiting period.</p>
<h3>Changed Your Mind?</h3>
<p>You can cancel at any time during the 14-day waiting period by logging in and clicking "Cancel Deletion" in your account settings.</p>
<p><strong>If you take no action</strong>, your account will be automatically deleted after the 14-day waiting period.</p>
`,
}),
});