You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f97badf
Browse filesBrowse the repository at this point in the historyBrowse files
fix(billing): stop account deletion from resetting the free allowance
Self-service deletion cascades the usage ledger with the user row, and signup
grants every new user row the free allowance, so deleting an account and
signing up again on the same email, Google, GitHub, or Microsoft identity
reset the one-time free credit.
Deletion at the holder's request now keeps keyed digests (HMAC-SHA256 under a
purpose-bound key derived from BETTER_AUTH_SECRET) of the account's canonical
email and social sign-in subjects for 365 days, and a new account on a matching
identity is created without the free allowance. The SCIM provisioning rollback
records nothing, and nothing is kept where billing is disabled.
- The allowance is a per-user `user_stats.free_tier_eligible` fact, so plan
re-syncs, the null-limit heal, usage reads, and admin grants keep it
withheld while prepaid credit and paid plans are unaffected.
- Signup checks the email and any sign-in already linked; a social sign-in
committed after the user hook is checked only when it was created in the
same auth request as its user, so linking a sign-in to an existing or
provisioned user later never withholds anything.
- A stats row created by the fallback (signup failed to create it) gets the
same check, failing open without failing the caller.
- Forfeiting sets the flag and re-derives the limit in one transaction.
- The deletion dialog says free credits are granted once per person.
Migration 0433 adds the `deleted_account_identity` table and the
`free_tier_eligible` column (constant default, metadata-only).
0 commit comments