Skip to content

Implement password reset and account deletion features - #4

Merged
ZeroElemental merged 2 commits into
mainfrom
dev
Aug 28, 2026
Merged

ZeroElemental merged 2 commits into
mainfrom
dev

Conversation

@ZeroElemental

Copy link
Copy Markdown
Owner

This pull request introduces a complete password reset flow, adds account deletion functionality, and refactors content pages for modularity and improved user experience. The most important changes are grouped below:

1. Password Reset Flow

2. Account Deletion

3. Content Page Refactoring

4. Validation and Security Improvements

About and FAQ used to be routes, so reading either from the chat threw away
the conversation you were looking at. Their bodies moved into components that
both a page and a dialog can render; the header and the three-dots menu now
open them over whatever you were doing, and the routes stay for direct links.

Forgot password. A recovery link goes to the existing callback, which forwards
to /auth/reset once the code is exchanged. The request form answers the same
way whether or not the address has an account -- signIn already flattens its
error for that reason, and anything else turns the form into an oracle.
/forgot-password joins AUTH_PAGES; /auth/reset is PROTECTED instead, because
the recovery link leaves a session behind and listing it as an auth page would
bounce exactly the person who needs it.

Delete account, behind a type-your-username confirmation. There is no
service-role key here, so it goes through a security definer function rather
than the admin API. Order matters in that function: attachment paths live only
on the caller's messages and those cascade, so the storage rows go first. It
also deletes the caller's conversations outright -- the reaper added in
20260825133149 fires at zero members, so a two-person chat losing one side
would otherwise strand the conversation, the peer's membership and the peer's
messages with nobody able to reach them. rls_test.sql now asserts that, and
that the peer's own account survives.

Fixed on the way past: the auth callback interpolated its `next` parameter
straight into the redirect, so ?next=//evil.com walked the user off the site.
It goes through safeRedirectPath now, like every other caller. Reset links
carry a `next`, which is what made it load-bearing.
Supabase installs a storage.protect_delete() trigger that rejects any direct
delete from storage.objects -- "Use the Storage API instead". Even the owner of
a security definer function hits it, and the 42501 aborted the entire deletion,
so the first version of this function could not delete an account at all.

Running the regression test against the real database is what surfaced it.

Storage is the client's job now. The dialog already removed the avatar through
the Storage API before calling the RPC, which is the path policies actually
permit and which deletes the bytes rather than just the row. Message
attachments stay orphaned in the bucket, as the comment there records: there is
no delete policy on that bucket and no service role to bypass it with.
@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pixel-chat Ready Ready Preview Aug 28, 2026 2:35pm

@ZeroElemental
ZeroElemental merged commit 4ddfbc2 into main Aug 28, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — b3019f30 Deployed Aug 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant